Page MenuHomePhabricator

ldd: Add GotEntrySize/GotPltEntrySize to ELF target

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



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/ -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/ -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:// 96b35f25c4f2253e9be5b814913106ec072a84d9)
[hjl@gnu-skl-1 pr28507]$ ./foo
[hjl@gnu-skl-1 pr28507]$

Diff Detail


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

LGTM with nits.

314–317 ↗(On Diff #63747)

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

84–87 ↗(On Diff #63747)


86–87 ↗(On Diff #63747)


This revision is now accepted and ready to land.Jul 12 2016, 4:20 PM added inline comments.Jul 12 2016, 5:40 PM
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.

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.