[ELF] Support --defsym=<symbol>=<symbol>.

Press ? to show keyboard shortcuts.
Committed
ruiuApr 16 2014, 1:58 PM
Differential Revision
D3332: [ELF] Support --defsym=<symbol>=<symbol>.
Parents
rL206416: Handle -m32 for NetBSD/sparc64 correctly. Extend test case to also check
Branches
Unknown
Tags
Unknown
Subscribers
None
Description

[ELF] Support --defsym=<symbol>=<symbol>.

Currently LLD supports --defsym only in the form of
--defsym=<symbol>=<integer>, where the integer is interpreted as the
absolute address of the symbol. This patch extends it to allow other
symbol name to be given as an RHS value. If a RHS value is a symbol
name, the LHS symbol will be defined as an alias for the RHS symbol.

Internally, a LHS symbol is represented as a zero-size defined atom
who has an LayoutAfter reference to an undefined atom, whose name is
the RHS value. Everything else is already implemented -- Resolver
will resolve the undefined symbol, and the layout pass will layout
the two atoms at the same location. Looks like it's working fine.

Note that GNU LD supports --defsym=<symbol>=<symbol>+<addend>. That
feature is out of scope of this patch.

Differential Revision: http://reviews.llvm.org/D3332

rL206417

lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h

Loading...

lld/trunk/lib/Driver/GnuLdDriver.cpp

Loading...

lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp

Loading...

lld/trunk/test/elf/X86_64/Inputs/fn.o

Loading...

lld/trunk/test/elf/X86_64/defsym.test

Loading...

lld/trunk/test/elf/defsym.objtxt

Loading...

lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp

Loading...

Add Comment