Page MenuHomePhabricator

ldd: Add GotEntrySize/GotPltEntrySize to ELF target
ClosedPublic

Authored by hjl.tools on Jul 12 2016, 4:07 PM.

Details

Summary

For x86-64 psABI, the entry size of .got and .got.plt sections is 8
bytes for both LP64 and ILP32. Add GotEntrySize and GotPltEntrySize
to ELF target instead of using size of ELFT::uint. Now we can generate
a simple working x32 executable:

[hjl@gnu-skl-1 pr28507]$ gcc -mx32 -B./ -o foo foo.o -Wl,-v
collect2 version 6.1.1 20160621 (Red Hat 6.1.1-3)
./ld -plugin /usr/libexec/gcc/x86_64-redhat-linux/6.1.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/6.1.1/lto-wrapper -plugin-opt=-fresolution=/tmp/ccSNGyqu.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf32_x86_64 -dynamic-linker /libx32/ld-linux-x32.so.2 -o foo /usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../libx32/crt1.o /usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../libx32/crti.o /usr/lib/gcc/x86_64-redhat-linux/6.1.1/x32/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/6.1.1/x32 -L/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../libx32 -L/lib/../libx32 -L/usr/lib/../libx32 -L. -L/usr/lib/gcc/x86_64-redhat-linux/6.1.1 -L/usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../.. foo.o -v -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-redhat-linux/6.1.1/x32/crtend.o /usr/lib/gcc/x86_64-redhat-linux/6.1.1/../../../../libx32/crtn.o
LLD 3.9 (ssh://llvm@gnu-4.sc.intel.com/export/server/git/llvm/lld 96b35f25c4f2253e9be5b814913106ec072a84d9)
[hjl@gnu-skl-1 pr28507]$ ./foo
hello
[hjl@gnu-skl-1 pr28507]$

Diff Detail

Repository
rL LLVM

Event Timeline

hjl.tools updated this revision to Diff 63747.Jul 12 2016, 4:07 PM
hjl.tools retitled this revision from to ldd: Add GotEntrySize/GotPltEntrySize to ELF target .
hjl.tools updated this object.
hjl.tools added a reviewer: ruiu.
hjl.tools set the repository for this revision to rL LLVM.
hjl.tools added a project: lld.
hjl.tools added a subscriber: llvm-commits.
ruiu accepted this revision.Jul 12 2016, 4:20 PM
ruiu edited edge metadata.

LGTM with nits.

ELF/Target.cpp
314–317 ↗(On Diff #63747)

Please reorder so that the order matches the member definitions in the base class.

ELF/Target.h
84–87 ↗(On Diff #63747)

Sort

86–87 ↗(On Diff #63747)

Sort.

This revision is now accepted and ready to land.Jul 12 2016, 4:20 PM
hjl.tools added inline comments.Jul 12 2016, 5:40 PM
ELF/Target.h
86–87 ↗(On Diff #63747)

What is the sorting order? Like this

unsigned GotEntrySize;
unsigned GotPltEntrySize;
unsigned PltEntrySize;
unsigned PltHeaderSize;
ruiu added a comment.Jul 12 2016, 5:50 PM

LGTM with nits.

ELF/Target.h
86–87 ↗(On Diff #63747)

Yeah. Since we are mixing uint32_t and unsigned, there's no single sort order, but at least for all members of the same type, I'd like to sort them alphabetically. So is it.

This revision was automatically updated to reflect the committed changes.