Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLD fails to link object file with version-extended symbol #30843

Closed
emaste opened this issue Dec 29, 2016 · 6 comments
Closed

LLD fails to link object file with version-extended symbol #30843

emaste opened this issue Dec 29, 2016 · 6 comments
Labels
bugzilla Issues migrated from bugzilla lld:ELF

Comments

@emaste
Copy link
Member

emaste commented Dec 29, 2016

Bugzilla Link 31495
Resolution FIXED
Resolved on Jan 06, 2017 16:45
Version unspecified
OS FreeBSD
Blocks #23588
CC @hfinkel,@rui314

Extended Description

FreeBSD's "pkg" package management tool is currently building an object file that depends on a compatibility symbol. I think this needs to be addressed in pkg itself, but GNU ld is able to link such an object.

LLD reports:

% ld.lld $(cat response.txt)
/tank/emaste/src/llvm/build-nodebug/bin/ld.lld: error: wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.7.2/libpkg/.libs/libpkg.lax/libbsd_compat.a/libbsd_compat_la-basename.o: symbol basename@FBSD_1.0 has undefined version FBSD_1.0
/tank/emaste/src/llvm/build-nodebug/bin/ld.lld: error: wrkdirs/usr/ports/ports-mgmt/pkg/work/pkg-1.7.2/libpkg/.libs/libpkg.lax/libbsd_compat.a/libbsd_compat_la-dirname.o: symbol dirname@FBSD_1.0 has undefined version FBSD_1.0

ld.bfd has no complaints:
% ld.bfd $(cat response.txt)
%

The offending symbol is basename@FBSD_1.0:

% readelf -s libbsd_compat_la-basename.o

Symbol table '.symtab' contains 5 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS basename.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 2
3: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND basename@FBSD_1.0
4: 0000000000000000 10 FUNC GLOBAL DEFAULT 2 bsd_basename

And indeed, a .o file has no symver information:

% readelf -V libbsd_compat_la-basename.o

No version information found in this file.

I suspect we should accept version-extended symbols from object files. Reprodcer available at https://people.freebsd.org/~emaste/lld/object-sym-version.cpio

@emaste
Copy link
Member Author

emaste commented Dec 29, 2016

See also freebsd/pkg#1522 for the pkg report.

@emaste
Copy link
Member Author

emaste commented Jan 3, 2017

pkg issue now addressed by freebsd/pkg@05ce724

@rui314
Copy link
Member

rui314 commented Jan 4, 2017

This must be a LLD's bug. If there is an undefined symbol foo@bar in an object file and there is an DSO defining foo with version bar, the undefined symbol should be resolved using the shared symbol.

@emaste
Copy link
Member Author

emaste commented Jan 4, 2017

This must be a LLD's bug.

I agree, if a foo@bar symbol appears in an object file lld should resolve it if the appropriate symbol and version appears in a DSO.

I just suspect that the use of such a symbol is reasonably likely to be unintentional, as it was with pkg. (Of course there also legitimate use cases for specific symbol versions, e.g. a unit test suite.)

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 6, 2017

reduced testcase
I reduced the testcase somewhat. I will try to fix this tomorrow if no one gets there first.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 7, 2017

291293

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla lld:ELF
Projects
None yet
Development

No branches or pull requests

3 participants