#6272 closed bug (fixed)
support for undefined weak symbols
Reported by: | lucian | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | System/Kernel | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Currently Haiku does not support add-ons with undefined weak symbols: it reports that a symbol could not be resolved and does not load the add-on.
As I understand it, undefined weak symbols should not be looked up, but just mapped to 0
http://www.delorie.com/gnu/docs/binutils/binutils_4.html
The symbol is a weak object. When a weak defined symbol is linked with a normal defined symbol, the normal defined symbol is used with no error. When a weak undefined symbol is linked and the symbol is not defined, the value of the weak symbol becomes zero with no error.
http://cygwin.ru/ml/binutils/2003-03/msg00450.html
"Unresolved weak symbols have a zero value".
Attachments (1)
Change History (6)
by , 14 years ago
Attachment: | elf-add-support-for-undefined-weak-symbols.patch added |
---|
comment:1 by , 14 years ago
patch: | 0 → 1 |
---|
comment:2 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-up: 4 comment:3 by , 14 years ago
Yep, you are right about not returning the symbol value. I meant to put the '*' but forgot.
I'm not sure how to read this binutils mailing list discussion: http://sourceware.org/ml/binutils/2010-03/msg00173.html
Because undefined weak references do not cause library archive symbols to be pulled in to resolve them, IIRC.
My interpretation is that the undefined weak symbol should only be searched inside the image in which it appears, not in other images.
That's why I put the check before elf_find_symbol
.
follow-up: 5 comment:4 by , 14 years ago
Replying to lucian:
I'm not sure how to read this binutils mailing list discussion: http://sourceware.org/ml/binutils/2010-03/msg00173.html
Because undefined weak references do not cause library archive symbols to be pulled in to resolve them, IIRC.
My interpretation is that the undefined weak symbol should only be searched inside the image in which it appears, not in other images.
This is what the System V ABI specification has to say (chapter 4, Symbol Table):
"When the link editor searches archive libraries [see ‘‘Archive File’’ in Chapter 7], it extracts archive members that contain definitions of undefined global symbols. The member’s definition may be either a global or a weak symbol. The link editor does not extract archive members to resolve undefined weak symbols. Unresolved weak symbols have a zero value."
That pretty explicitly only refers to the link editor, i.e. the linker, not the dynamic loader, and archive (i.e. static) libraries, which aren't of relevance for the loader. I found no other mention of weak undefined symbols in the specification. Sun seems to agree with this interpretation.
comment:5 by , 14 years ago
Yep, you're right. I misinterpreted that discussion. Thanks for making things clearer.
*sigh* Trac swallowed my comment.
The short version again: The patch has two problems: You never actually return the symbol value and you return too early. Implemented correctly in hrev37412.