Opened 13 years ago

Closed 3 years ago

#8288 closed bug (fixed)

Undefined weak symbols should get a value of 0

Reported by: hamish Owned by: bonefish
Priority: normal Milestone: R1/beta4
Component: System/runtime_loader Version: R1/Development
Keywords: undefined weak symbols Cc: cian
Blocked By: Blocking:
Platform: All

Description

This has apparently already been fixed for kernel code in #6272 but persists in runtime_loader. Weak symbols that are unresolved should get set to 0.

For example, this program should run and return successfully:

#include <stdlib.h>
extern void func() __attribute__ ((weak));
int main() {
    // Always false but won't be optimized away.
    if (malloc(1)==(void*)1) func();
    return 0;
}

But instead runtime_loader complains about unresolved symbols.

Attachments (1)

UndefinedWeakSymbols0.patch (1.2 KB ) - added by hamish 13 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by X512, 13 years ago

Is this related to unsolved symbols of reserved methods like «_ZN5BView15_ReservedView12Ev» when this virtual methods are implemented?

comment:2 by bonefish, 13 years ago

I could have sworn the feature was implemented in the runtime loader at the same time, but obviously that's not the case.

The implementation is rather easy: In resolve_symbol() lookupError simply needs to remain ERROR_UNPATCHED, if sym is weak (i.e. put the assignment in a respective "if").

I can't promise that I get to implement it anytime soon. So, if there are any takers ...

by hamish, 13 years ago

Attachment: UndefinedWeakSymbols0.patch added

comment:3 by hamish, 13 years ago

patch: 01

comment:4 by bonefish, 13 years ago

Mmh, the symbol patcher stuff makes that all a bit more complicated. The interface has to be changed, I'm afraid. We should also fix the incorrect assumption that a value of NULL means the symbol is undefined.

comment:5 by cian, 12 years ago

This is currently affecting doing a clean build of VLC/libvlc - weak symbol in the core library leads to runtime errors when trying to run the application or even test suites.

If the code is edited to use the non-weak version (intended for non-ELF targets), it works.

comment:6 by cian, 12 years ago

Cc: cian added

comment:7 by waddlesplash, 3 years ago

Milestone: R1R1/beta4
Resolution: fixed
Status: newclosed

Fixed in hrev55850.

Note: See TracTickets for help on using tickets.