27 lines · plain
1// REQUIRES: x862// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o3// RUN: ld.lld %t.o -shared -o %t.so4// RUN: llvm-readelf -S %t.so | FileCheck %s -check-prefix=SECTION5// RUN: llvm-objdump --no-print-imm-hex -d %t.so | FileCheck %s6 7// SECTION: .dynamic DYNAMIC 00000000000022908// SECTION: .got.plt PROGBITS 0000000000003300 000300 0000189 10// The assembly is generated by11// gcc -O2 -S -mcmodel=medium -fPIC a.c12// This computes the pc-relative address (runtime address) of _DYNAMIC.13//14// extern long _DYNAMIC[] __attribute__((visibility("hidden")));15// long* dynamic() { return _DYNAMIC; }16 17// 0x3300 (.got.plt) - 0x127b = 832518// 0x2290 (_DYNAMIC) - 0x3300 (.got.plt) = -420819// CHECK: 1274: {{.*}} leaq 8325(%rip), %rdx20// CHECK-NEXT: 127b: {{.*}} movabsq $-4208, %rax21.global dynamic22dynamic:23 leaq _GLOBAL_OFFSET_TABLE_(%rip), %rdx24 movabsq $_DYNAMIC@GOTOFF, %rax25 addq %rdx, %rax26 ret27