bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/17592] New: x86-64 linker generates wrong PLT for large model


From: hjl.tools at gmail dot com
Subject: [Bug ld/17592] New: x86-64 linker generates wrong PLT for large model
Date: Wed, 12 Nov 2014 22:34:11 +0000

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

            Bug ID: 17592
           Summary: x86-64 linker generates wrong PLT for large model
           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

When PLT is more 2GB from GOT, we must use large model PLT layout.
Otherwise, PLT entry can't load GOT entry:

address@hidden large-2]$ cat main.c 
extern void foo (void);
extern void bar (void);

int
main ()
{
  foo ();
  bar ();
  return 0;
}
address@hidden large-2]$ cat foo.c 
#include <stdio.h>

void
foo (void)
{
  printf ("hello\n");
}
address@hidden large-2]$ cat gap.S 
    .text
    .p2align 4,,15
    .globl    bar
    .type    bar, @function
bar:
    jmp .L0
    .space 0x40000000, 0x90
.L0:
    jmp .L2
    .space 0x3fdffe14, 0x90
.L2:
    leaq    .L2(%rip), %rcx
    movabsq    $_GLOBAL_OFFSET_TABLE_-.L2, %r11
    movabsq    address@hidden, %rax
    addq    %r11, %rcx
    addq    %rcx, %rax
    jmp    *%rax
    .size    bar, .-bar
    .section    .note.GNU-stack,"",@progbits
address@hidden large-2]$ make
gcc -O2   -c -o main.o main.c
gcc -O2 -c -o gap.o gap.S
gcc -O2 -mcmodel=large -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
address@hidden large-2]$

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]