i386: Test external function reference without PLT
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 8 Jun 2016 19:41:50 +0000 (12:41 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 8 Jun 2016 19:41:50 +0000 (12:41 -0700)
commitffc89b17f2a432389ef15485fa887231a0d2b6c3
tree4a4bca866054899853806b905efc3ac1c446c681
parentdcc03cb3662740029b2dde3e0a3c10692ebda054
i386: Test external function reference without PLT

To call an external function, the direct branch to the PLT entry can be
replaced by an indirect branch via the GOT slot, which is similar to the
first instruction in the PLT slot.  Instead using the PLT slot as function
address, the function address is retrieved from the GOT slot.  The
R_386_GOT32X relocation can be used to compute the address of the symbol’s
GOT entry without base register when PIC is disabled.  In non-PIC
executable,

call/jmp *func@GOT

should be used for indirect branch via the GOT slot and

movl func@GOT, %eax

should be used to load function address.  Unlike PIC case, no register
is needed to access GOT.  If linker determines the function is defined
locally, it converts indirect branch via the GOT slot to direct branch
with a nop prefix and converts load via the GOT slot to load immediate
or lea.

* testsuite/ld-i386/libno-plt-1b.dd: New file.
* testsuite/ld-i386/libno-plt-1b.rd: Likewise.
* testsuite/ld-i386/no-plt-1a.dd: Likewise.
* testsuite/ld-i386/no-plt-1a.rd: Likewise.
* testsuite/ld-i386/no-plt-1b.dd: Likewise.
* testsuite/ld-i386/no-plt-1b.rd: Likewise.
* testsuite/ld-i386/no-plt-1c.dd: Likewise.
* testsuite/ld-i386/no-plt-1c.rd: Likewise.
* testsuite/ld-i386/no-plt-1d.dd: Likewise.
* testsuite/ld-i386/no-plt-1d.rd: Likewise.
* testsuite/ld-i386/no-plt-1e.dd: Likewise.
* testsuite/ld-i386/no-plt-1e.rd: Likewise.
* testsuite/ld-i386/no-plt-1f.dd: Likewise.
* testsuite/ld-i386/no-plt-1f.rd: Likewise.
* testsuite/ld-i386/no-plt-1g.dd: Likewise.
* testsuite/ld-i386/no-plt-1g.rd: Likewise.
* testsuite/ld-i386/no-plt-1h.dd: Likewise.
* testsuite/ld-i386/no-plt-1h.rd: Likewise.
* testsuite/ld-i386/no-plt-1i.dd: Likewise.
* testsuite/ld-i386/no-plt-1i.rd: Likewise.
* testsuite/ld-i386/no-plt-1j.dd: Likewise.
* testsuite/ld-i386/no-plt-1j.rd: Likewise.
* testsuite/ld-i386/no-plt-check1a.S: Likewise.
* testsuite/ld-i386/no-plt-check1b.S: Likewise.
* testsuite/ld-i386/no-plt-extern1a.S: Likewise.
* testsuite/ld-i386/no-plt-extern1b.S: Likewise.
* testsuite/ld-i386/no-plt-func1.c: Likewise.
* testsuite/ld-i386/no-plt-main1.c: Likewise.
* testsuite/ld-i386/no-plt.exp: Likewise.
29 files changed:
ld/testsuite/ld-i386/libno-plt-1b.dd [new file with mode: 0644]
ld/testsuite/ld-i386/libno-plt-1b.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1a.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1a.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1b.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1b.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1c.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1c.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1d.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1d.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1e.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1e.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1f.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1f.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1g.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1g.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1h.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1h.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1i.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1i.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1j.dd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-1j.rd [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-check1a.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-check1b.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-extern1a.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-extern1b.S [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-func1.c [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt-main1.c [new file with mode: 0644]
ld/testsuite/ld-i386/no-plt.exp [new file with mode: 0644]