X86-64 linker fails to check PC-relative offset overflow in PLT entry: [hjl@gnu-6 plt]$ cat foo.c #include <stdio.h> void foo (void) { printf ("PASS\n"); } [hjl@gnu-6 plt]$ cat main.c extern void foo (void); extern void bar (void); int main () { foo (); bar (); return 0; } [hjl@gnu-6 plt]$ cat gap.S .text .p2align 4,,15 .globl bar .type bar, @function bar: jmp .L0 .space 0x40000000, 0x90 .L0: jmp .L2 #ifdef GOLD .space 0x4fdfff14, 0x90 #else .space 0x3fdfff14, 0x90 #endif .L2: leaq .L2(%rip), %rcx movabsq $_GLOBAL_OFFSET_TABLE_-.L2, %r11 movabsq $foo@PLTOFF, %rax addq %r11, %rcx addq %rcx, %rax jmp *%rax .size bar, .-bar .section .note.GNU-stack,"",@progbits [hjl@gnu-6 plt]$ make LD=ld gcc -O2 -c -o main.o main.c gcc -O2 -c -o gap.o gap.S gcc -O2 -fpic -c -o foo.o foo.c ld -shared -o libfoo.so gap.o foo.o gcc -O2 -o foo main.o libfoo.so -Wl,-R,. ./foo make: *** [all] Segmentation fault [hjl@gnu-6 plt]$
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gdb and binutils". The branch, master has been updated via ab7fede88eddf004994f8769e3c7ac145628f5b4 (commit) from 439247b656ce3bcfaa00fec7dbce70e65ca17cf5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ab7fede88eddf004994f8769e3c7ac145628f5b4 commit ab7fede88eddf004994f8769e3c7ac145628f5b4 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Nov 18 11:03:09 2014 -0800 Check PC-relative offset overflow in PLT entry This patch checks PC-relative offset overflow in pushq instruction in x86-64 PLT entry. bfd/ PR ld/17618 * elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check PC-relative offset overflow in PLT entry. ld/testsuite/ PR ld/17618 * ld-x86-64/x86-64.exp: Run pr17618 for Linux target. * ld-x86-64/pr17618.d: New file. * ld-x86-64/pr17618.s: Likewise. ----------------------------------------------------------------------- Summary of changes: bfd/ChangeLog | 6 ++++++ bfd/elf64-x86-64.c | 27 +++++++++++++++++++-------- ld/testsuite/ChangeLog | 8 ++++++++ ld/testsuite/ld-x86-64/pr17618.d | 4 ++++ ld/testsuite/ld-x86-64/pr17618.s | 18 ++++++++++++++++++ ld/testsuite/ld-x86-64/x86-64.exp | 7 +++++++ 6 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 ld/testsuite/ld-x86-64/pr17618.d create mode 100644 ld/testsuite/ld-x86-64/pr17618.s
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=978c05401b0f0ac7a94cca7db19b1dec0c5bd698 commit 978c05401b0f0ac7a94cca7db19b1dec0c5bd698 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Aug 9 15:04:05 2017 -0700 Run PR ld/17618 test only with 64-bit ELF linker PR ld/17618 test requires 64-bit linker to run. Set LD_CLASS to "64bit" for 64-bit ELF linker and run PR ld/17618 test only if $LD_CLASS is "64bit". More checks can be added to support 64-bit linkers in non-ELF format. * testsuite/config/default.exp (LD_CLASS): New. Set to "64bit" for 64-bit ELF linker. * testsuite/ld-x86-64/pr17618.d (#notarget): Removed. * testsuite/ld-x86-64/x86-64.exp: Run pr17618 only for 64-bit linker.
Fixed.