This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by ruiu on Apr 9 2014, 3:11 PM.

Details

Summary

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, a 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.

Diff Detail

Repository
rL LLVM

Event Timeline

shankarke accepted this revision.Apr 9 2014, 4:49 PM

LGTM.

atanasyan requested changes to this revision.Apr 17 2014, 7:42 AM
atanasyan added inline comments.
include/lld/ReaderWriter/ELFLinkingContext.h
235 ↗(On Diff #8447)

I think it is a typo here. The map should be returned be reference not value.

ruiu closed this revision.May 19 2014, 7:23 AM
ruiu updated this revision to Diff 9537.

Closed by commit rL206417 (authored by @ruiu).