Skip to content

Commit 4b82cef

Browse files
jrtc27resistor
authored andcommitted
[ELF][Mips] Remove --building-freebsd-rtld
This is MIPS-specific as a downstream hack.
1 parent 0f171db commit 4b82cef

File tree

7 files changed

+1
-81
lines changed

7 files changed

+1
-81
lines changed

lld/ELF/Arch/Cheri.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -963,12 +963,6 @@ void addCapabilityRelocation(
963963
"ELF relocs should not be used for non-preemptible symbols");
964964
assert((!sym->isLocal() || needTrampoline) &&
965965
"ELF relocs should not be used for local symbols");
966-
if (ctx.arg.emachine == llvm::ELF::EM_MIPS && ctx.arg.buildingFreeBSDRtld) {
967-
error("relocation " + toStr(ctx, type) + " against " +
968-
verboseToString(ctx, sym) +
969-
" cannot be using when building FreeBSD RTLD" + referencedBy());
970-
return;
971-
}
972966
if (!lld::elf::hasDynamicLinker(ctx)) {
973967
error("attempting to emit a R_CAPABILITY relocation against " +
974968
(sym->getName().empty() ? "local symbol"

lld/ELF/Config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ struct Config {
312312
bool asNeeded = false;
313313
bool armBe8 = false;
314314
BsymbolicKind bsymbolic = BsymbolicKind::None;
315-
// make dynamic relocations that are not supported by
316-
// FreeBSD _rtld_relocate_nonplt_self an error.
317-
bool buildingFreeBSDRtld;
318315
CGProfileSortKind callGraphProfileSort;
319316
llvm::StringRef irpgoProfilePath;
320317
bool bpStartupFunctionSort = false;

lld/ELF/Driver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,6 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
14071407
else if (arg->getOption().matches(OPT_Bsymbolic))
14081408
ctx.arg.bsymbolic = BsymbolicKind::All;
14091409
}
1410-
ctx.arg.buildingFreeBSDRtld = args.hasArg(OPT_building_freebsd_rtld);
14111410
ctx.arg.callGraphProfileSort = getCGProfileSortKind(ctx, args);
14121411
parseBPOrdererOptions(ctx, args);
14131412
ctx.arg.capTableScope = getCapTableScope(args);

lld/ELF/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,11 +819,7 @@ def: J<"plugin-opt=-pass-through=">;
819819
// -plugin-opt=path/to/{liblto_plugin.so,lto-wrapper}
820820
def plugin_opt_eq : J<"plugin-opt=">;
821821

822-
823822
// CHERI options:
824-
def building_freebsd_rtld : F<"building-freebsd-rtld">,
825-
HelpText<"Disallow any relocations that are not "
826-
"supported by _rtld_relocate_nonplt_self">;
827823
defm sort_cap_relocs: B<"sort-cap-relocs",
828824
"Sort the __cap_relocs section by capability location",
829825
"Do not sort the __cap_relocs section by capability location">, Flags<[HelpHidden]>;

lld/ELF/SyntheticSections.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,18 +1813,6 @@ void RelocationBaseSection::finalizeContents() {
18131813
warn("attempting to add a dynamic relocation against the __cap_relocs "
18141814
"section.");
18151815
}
1816-
if (ctx.arg.emachine == EM_MIPS && ctx.arg.buildingFreeBSDRtld) {
1817-
unsigned baseRelocType = reloc.type & 0xff;
1818-
if (baseRelocType != R_MIPS_REL32 && baseRelocType != R_MIPS_NONE) {
1819-
auto diag = Err(ctx);
1820-
diag << "relocation " << toStr(ctx, reloc.type) << " against "
1821-
<< toStr(ctx, *reloc.sym)
1822-
<< " cannot be using when building FreeBSD RTLD";
1823-
1824-
printLocationMessage(diag, *reloc.inputSec, *reloc.sym,
1825-
reloc.offsetInSec);
1826-
}
1827-
}
18281816
}
18291817
}
18301818

@@ -4892,10 +4880,7 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
48924880

48934881
// Add MIPS-specific sections.
48944882
if (ctx.arg.emachine == EM_MIPS) {
4895-
// XXXAR: also add the RLD_MAP dynamic tags to rtld so that we can use
4896-
// gdb with rtld direct exec mode.
4897-
// TODO: should probably try to build rtld as PIE instead?
4898-
if ((!ctx.arg.shared || ctx.arg.buildingFreeBSDRtld) && ctx.hasDynsym) {
4883+
if (!ctx.arg.shared && ctx.hasDynsym) {
48994884
ctx.in.mipsRldMap = std::make_unique<MipsRldMapSection>(ctx);
49004885
add(*ctx.in.mipsRldMap);
49014886
}

lld/test/ELF/cheri/building-rtld.s

Lines changed: 0 additions & 29 deletions
This file was deleted.

lld/test/ELF/cheri/cap-table/local-fn-ptr-in-plt-abi.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// RUN: llvm-objdump --syms %t-shlib.so | FileCheck %s --check-prefix SHLIB-DUMP
1717
// SHLIB-DUMP: 0000000000010380 g F .text 000000{{[0-9a-f]+}} use_callback
1818

19-
20-
// Should not build with the --building-freebsd-rtld flag
2119
// Check that we emit a R_CHERI_CAPABILITY relocation instead of __cap_relocs for shlib/pie/dynamically linked exe
2220
// RUN: ld.lld -shared %t.o %t-shlib.so -o %t.so --verbose-cap-relocs 2>&1 | FileCheck %s -check-prefixes VERBOSE-MSG
2321
// RUN: llvm-readobj --dyn-symbols --dyn-relocations --cap-relocs --cap-table %t.so | FileCheck %s --check-prefixes CHECK,CHECK-SHLIB
@@ -129,26 +127,6 @@
129127
// STATIC-NEXT: 0x20 global_return2@CAPTABLE
130128
// STATIC-NEXT: ]
131129

132-
// Should not build as RTLD (due to the R_CHERI_CAPABILITY relocation)
133-
// RUN: not ld.lld -Bsymbolic -shared --building-freebsd-rtld %t.o %t-shlib.o --verbose-cap-relocs -o /dev/null 2>&1 | FileCheck %s -check-prefix RTLD-ERROR
134-
// RTLD-ERROR: Using trampoline for function pointer against local function return1
135-
// RTLD-ERROR-NEXT: >>> defined in ({{.+}}local-fn-ptr-in-plt-abi.c.tmp.o:(function return1{{.+}}))
136-
// RTLD-ERROR-NEXT: ld.lld: error: relocation R_MIPS_CHERI_CAPABILITY against local function return1
137-
// RTLD-ERROR-NEXT: >>> defined in ({{.+}}local-fn-ptr-in-plt-abi.c.tmp.o:(function return1{{.+}})) cannot be using when building FreeBSD RTLD
138-
// RTLD-ERROR-NEXT: >>> referenced by [email protected]
139-
// RTLD-ERROR-NEXT: >>> first used in function __start
140-
// RTLD-ERROR-NEXT: >>> defined in ({{.+}}local-fn-ptr-in-plt-abi.c.tmp.o:(function __start{{.+}}))
141-
142-
// RTLD-ERROR-NEXT: Using trampoline for function pointer against function global_return2
143-
// RTLD-ERROR-NEXT: >>> defined in ({{.+}}local-fn-ptr-in-plt-abi.c.tmp.o:(function global_return2{{.+}}))
144-
// RTLD-ERROR-EMPTY:
145-
// RTLD-ERROR-NEXT: ld.lld: error: relocation R_MIPS_CHERI_CAPABILITY against function global_return2
146-
// RTLD-ERROR-NEXT: >>> defined in ({{.+}}local-fn-ptr-in-plt-abi.c.tmp.o:(function global_return2{{.+}})) cannot be using when building FreeBSD RTLD
147-
// RTLD-ERROR-NEXT: >>> referenced by global_return2@CAPTABLE
148-
// RTLD-ERROR-NEXT: >>> first used in function __start
149-
// RTLD-ERROR-NEXT: >>> defined in ({{.+}}local-fn-ptr-in-plt-abi.c.tmp.o:(function __start{{.+}}))
150-
// RTLD-ERROR-EMPTY:
151-
152130
// Check that we don't crash when a version script marks a symbol as non-preemptible:
153131
// RUN: echo "VERSION_1.0 { local: *; };" > %t.script
154132
// RUN: ld.lld -shared %t.o %t-shlib.so --verbose-cap-relocs -o %t-version-script.so --version-script %t.script

0 commit comments

Comments
 (0)