https://sourceware.org/bugzilla/show_bug.cgi?id=17618

            Bug ID: 17618
           Summary: Linker fails to check PC-relative offset overflow in
                    PLT entry
           Product: binutils
           Version: 2.26 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com

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]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to