bug-binutils
[Top][All Lists]
Advanced

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

[Bug gold/19169] New: Gold emits incorrect R_AARCH64_ABS64


From: eugeni.stepanov at gmail dot com
Subject: [Bug gold/19169] New: Gold emits incorrect R_AARCH64_ABS64
Date: Sat, 24 Oct 2015 00:51:43 +0000

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

            Bug ID: 19169
           Summary: Gold emits incorrect R_AARCH64_ABS64
           Product: binutils
           Version: 2.24
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: eugeni.stepanov at gmail dot com
                CC: ian at airs dot com
  Target Milestone: ---

The following code, when placed in a non-symbolically linked shared library,
fails on Android/AArch64 when linked with gold.

int A[10] = {1, 0};
int *B = A;

extern "C" void f() {
  int *C = A;
  assert(B == C);
}


Let's reduce it to:

int A[10] = {1, 0};
int *B = A;

$ objdump -t 1.o
0000000000000000 g     O .data  0000000000000028 A
0000000000000000 g     O .data.rel      0000000000000008 B

$ objdump -r 1.o
RELOCATION RECORDS FOR [.data.rel]:
OFFSET           TYPE              VALUE 
0000000000000000 R_AARCH64_ABS64   A

$ objdump -s -j .data.rel 1.o
Contents of section .data.rel:
 0000 00000000 00000000                    ........

Link with gold.

$ objdump -T gold.so
0000000000002018 g    DO .data  0000000000000028 A
0000000000002040 g    DO .data  0000000000000008 B

$ objdump -R gold.so
DYNAMIC RELOCATION RECORDS
OFFSET           TYPE              VALUE 
0000000000001e28 R_AARCH64_RELATIVE  *ABS*+0x00000000000003e0
0000000000002040 R_AARCH64_ABS64   A

$ objdump -s -j .data gold.so
Contents of section .data:
 2010 00000000 00000000 01000000 00000000  ................
 2020 00000000 00000000 00000000 00000000  ................
 2030 00000000 00000000 00000000 00000000  ................
 2040 18200000 00000000                    . ......        

The addend at 0x2040 is not zero. This makes B point to A + 0x182.
The addend should be zero.


To reproduce:
grab android-ndk-r10e from google
./build/tools/make-standalone-toolchain.sh --toolchain
aarch64-linux-android-clang3.6 --platform=android-21
--install-dir=standalone-clang-aarch64
cd standalone-clang-aarch64
cat >1.cc
int A[10] = {1, 0};
int *B = A;
^D
./bin/clang++ 1.cc -shared -fPIC -o 1.so -fuse-ld=gold
objdump -s -j .data 1.so

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