Skip to content

Commit c69fafe

Browse files
author
git apple-llvm automerger
committed
Merge commit '9267caebfa92' from llvm.org/master into apple/main
2 parents 008cbdb + 9267cae commit c69fafe

File tree

2 files changed

+5
-43
lines changed

2 files changed

+5
-43
lines changed

lld/ELF/Relocations.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,28 +1319,6 @@ static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i,
13191319
int64_t addend = computeAddend<ELFT>(rel, end, sec, expr, sym.isLocal());
13201320

13211321
if (config->emachine == EM_PPC64) {
1322-
// For a call to __tls_get_addr, the instruction needs to be relocated by
1323-
// two relocations, R_PPC64_TLSGD/R_PPC64_TLSLD and R_PPC64_REL24[_NOTOC].
1324-
// R_PPC64_TLSGD/R_PPC64_TLSLD should precede R_PPC64_REL24[_NOTOC].
1325-
if ((type == R_PPC64_REL24 || type == R_PPC64_REL24_NOTOC) &&
1326-
sym.getName() == "__tls_get_addr") {
1327-
bool err = i - start < 2;
1328-
if (!err) {
1329-
// Subtract 2 to get the previous iterator because we have already done
1330-
// ++i above. This is now safe because we know that i-1 is not the
1331-
// start.
1332-
const RelTy &prevRel = *(i - 2);
1333-
RelType prevType = prevRel.getType(config->isMips64EL);
1334-
err = prevRel.r_offset != rel.r_offset ||
1335-
(prevType != R_PPC64_TLSGD && prevType != R_PPC64_TLSLD);
1336-
}
1337-
1338-
if (err)
1339-
errorOrWarn("call to __tls_get_addr is missing a "
1340-
"R_PPC64_TLSGD/R_PPC64_TLSLD relocation" +
1341-
getLocation(sec, sym, offset));
1342-
}
1343-
13441322
// We can separate the small code model relocations into 2 categories:
13451323
// 1) Those that access the compiler generated .toc sections.
13461324
// 2) Those that access the linker allocated got entries.

lld/test/ELF/ppc64-tls-missing-gdld.s

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
# REQUIRES: ppc
22
# RUN: llvm-mc --triple=powerpc64le %s --filetype=obj -o %t1.o
33
# RUN: llvm-mc --triple=powerpc64 %s --filetype=obj -o %t2.o
4-
# RUN: not ld.lld --shared %t1.o -o /dev/null 2>&1 | FileCheck %s
5-
# RUN: not ld.lld --shared %t2.o -o /dev/null 2>&1 | FileCheck %s
4+
# RUN: ld.lld --shared --fatal-warnings %t1.o -o /dev/null
5+
# RUN: ld.lld --shared --fatal-warnings %t2.o -o /dev/null
66

7-
# CHECK: ld.lld: error: call to __tls_get_addr is missing a R_PPC64_TLSGD/R_PPC64_TLSLD relocation
8-
# CHECK-NEXT: defined in {{.*}}.o
9-
# CHECK-NEXT: referenced by {{.*}}.o:(.text+0x8)
10-
11-
# CHECK: ld.lld: error: call to __tls_get_addr is missing a R_PPC64_TLSGD/R_PPC64_TLSLD relocation
12-
# CHECK-NEXT: defined in {{.*}}.o
13-
# CHECK-NEXT: referenced by {{.*}}.o:(.text+0x18)
14-
15-
# CHECK: ld.lld: error: call to __tls_get_addr is missing a R_PPC64_TLSGD/R_PPC64_TLSLD relocation
16-
# CHECK-NEXT: defined in {{.*}}.o
17-
# CHECK-NEXT: referenced by {{.*}}.o:(.text+0x28)
18-
19-
# CHECK: ld.lld: error: call to __tls_get_addr is missing a R_PPC64_TLSGD/R_PPC64_TLSLD relocation
20-
# CHECK-NEXT: defined in {{.*}}.o
21-
# CHECK-NEXT: referenced by {{.*}}.o:(.text+0x38)
22-
23-
# CHECK: ld.lld: error: call to __tls_get_addr is missing a R_PPC64_TLSGD/R_PPC64_TLSLD relocation
24-
# CHECK-NEXT: defined in {{.*}}.o
25-
# CHECK-NEXT: referenced by {{.*}}.o:(.text+0x40)
7+
## User code can call __tls_get_addr by specifying the tls_index parameter.
8+
## We need to allow R_PPC64_REL24/R_PPC64_REL24_NOTOC referencing __tls_get_addr
9+
## without a pairing R_PPC64_TLSGD/R_PPC64_TLSLD.
2610

2711
GeneralDynamic:
2812
addis 3, 2, x@got@tlsgd@ha

0 commit comments

Comments
 (0)