return 0;
}
+// True if non-preemptable symbol always has the same value regardless of where
+// the DSO is loaded.
+template <class ELFT> static bool isAbsolute(const SymbolBody &Body) {
+ if (Body.isUndefined() && Body.isWeak())
+ return true; // always 0
+ if (const auto *DR = dyn_cast<DefinedRegular<ELFT>>(&Body))
+ return DR->Section == nullptr; // Absolute symbol.
+ return false;
+}
+
// The reason we have to do this early scan is as follows
// * To mmap the output file, we need to know the size
// * For that, we need to know how many dynamic relocs we will have.
// can process some of it and and just ask the dynamic linker to add the
// load address.
if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC ||
- Expr == R_SIZE || (Body.isUndefined() && Body.isWeak())) {
+ Expr == R_SIZE || isAbsolute<ELFT>(Body)) {
if (Config->EMachine == EM_MIPS && Body.isLocal() &&
(Type == R_MIPS_GPREL16 || Type == R_MIPS_GPREL32))
Expr = R_MIPS_GP0;
--- /dev/null
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/abs-hidden.s -o %t2.o
+// RUN: ld.lld %t.o %t2.o -o %t.so -shared
+// RUN: llvm-readobj -r -s -section-data %t.so | FileCheck %s
+
+ .quad foo
+
+// CHECK: Name: .text
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_EXECINSTR
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address:
+// CHECK-NEXT: Offset:
+// CHECK-NEXT: Size: 8
+// CHECK-NEXT: Link: 0
+// CHECK-NEXT: Info: 0
+// CHECK-NEXT: AddressAlignment: 4
+// CHECK-NEXT: EntrySize: 0
+// CHECK-NEXT: SectionData (
+// CHECK-NEXT: 0000: 42000000 00000000
+// CHECK-NEXT: )
+
+// CHECK: Relocations [
+// CHECK-NEXT: ]