This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ld can leave undefined symbols in non-relocatable output


Hi everyone,

I'm on x86_64 using binutils 2.18.0 on GNU/Linux. I've recently run
across some counterintuitive behavior in the linker, but I'm not sure
whether it's intended or not. I was hoping someone on this list might
be able to clarify whether this is intended and dependable behavior,
or a bug.

% cat test.s
        .section .text
        .globl  _start
        .extern asym

        .equ    __need_asym, asym

_start:
        ret

% as -o test.o test.s
% ld -o test test.o
% nm test
0000000000600079 A __bss_start
0000000000600079 A _edata
0000000000600080 A _end
0000000000400078 T _start
                U asym

As you can see, the reference to "asym" remains undefined in the
output executable.

The use of an .equ statement to create undefined symbol references
originated in a need to "pull in" object files from an archive due to
configuration options, and it works well for that task. It has the
benefit of not increasing the output size, which is important in the
environment it's used in (the network boot ROM gPXE). However, I would
have expected the link to fail if the referenced symbol is not
available (as in this test case), and it does not. Any clarification
would be greatly appreciated.

Thank you,

-- Josh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]