Skip to content

Commit f6abc66

Browse files
committed
Revert "Revert "Revert "[lld][Arm] Big Endian - Byte invariant support."""
This reverts commit f146763.
1 parent b1a3b2c commit f6abc66

32 files changed

+68
-323
lines changed

lld/ELF/Arch/ARM.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ class ARM final : public TargetInfo {
4444
void relocate(uint8_t *loc, const Relocation &rel,
4545
uint64_t val) const override;
4646
};
47-
enum class CodeState { Data = 0, Thumb = 2, Arm = 4 };
4847
} // namespace
4948

50-
static DenseMap<InputSection *, SmallVector<const Defined *, 0>> sectionMap{};
51-
5249
ARM::ARM() {
5350
copyRel = R_ARM_COPY;
5451
relativeRel = R_ARM_RELATIVE;
@@ -71,24 +68,16 @@ uint32_t ARM::calcEFlags() const {
7168
// The ABIFloatType is used by loaders to detect the floating point calling
7269
// convention.
7370
uint32_t abiFloatType = 0;
74-
75-
// Set the EF_ARM_BE8 flag in the ELF header, if ELF file is big-endian
76-
// with BE-8 code.
77-
uint32_t armBE8 = 0;
78-
7971
if (config->armVFPArgs == ARMVFPArgKind::Base ||
8072
config->armVFPArgs == ARMVFPArgKind::Default)
8173
abiFloatType = EF_ARM_ABI_FLOAT_SOFT;
8274
else if (config->armVFPArgs == ARMVFPArgKind::VFP)
8375
abiFloatType = EF_ARM_ABI_FLOAT_HARD;
8476

85-
if (!config->isLE && config->armBe8)
86-
armBE8 = EF_ARM_BE8;
87-
8877
// We don't currently use any features incompatible with EF_ARM_EABI_VER5,
8978
// but we don't have any firm guarantees of conformance. Linux AArch64
9079
// kernels (as of 2016) require an EABI version to be set.
91-
return EF_ARM_EABI_VER5 | abiFloatType | armBE8;
80+
return EF_ARM_EABI_VER5 | abiFloatType;
9281
}
9382

9483
RelExpr ARM::getRelExpr(RelType type, const Symbol &s,

lld/ELF/Config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ struct Config {
203203
bool armHasMovtMovw = false;
204204
bool armJ1J2BranchEncoding = false;
205205
bool asNeeded = false;
206-
bool armBe8 = false;
207206
BsymbolicKind bsymbolic = BsymbolicKind::None;
208207
bool callGraphProfileSort;
209208
bool checkSections;

lld/ELF/Driver.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,9 @@ static void checkOptions() {
359359
if (config->fixCortexA8 && config->emachine != EM_ARM)
360360
error("--fix-cortex-a8 is only supported on ARM targets");
361361

362-
if (config->armBe8 && config->emachine != EM_ARM)
363-
error("--be8 is only supported on ARM targets");
364-
365362
if (config->fixCortexA8 && !config->isLE)
366363
error("--fix-cortex-a8 is not supported on big endian targets");
367-
364+
368365
if (config->tocOptimize && config->emachine != EM_PPC64)
369366
error("--toc-optimize is only supported on PowerPC64 targets");
370367

@@ -1124,7 +1121,6 @@ static void readConfigs(opt::InputArgList &args) {
11241121
OPT_no_android_memtag_stack, false);
11251122
config->androidMemtagMode = getMemtagMode(args);
11261123
config->auxiliaryList = args::getStrings(args, OPT_auxiliary);
1127-
config->armBe8 = args.hasArg(OPT_be8);
11281124
if (opt::Arg *arg =
11291125
args.getLastArg(OPT_Bno_symbolic, OPT_Bsymbolic_non_weak_functions,
11301126
OPT_Bsymbolic_functions, OPT_Bsymbolic)) {

lld/ELF/Options.td

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ multiclass B<string name, string help1, string help2> {
3636

3737
defm auxiliary: Eq<"auxiliary", "Set DT_AUXILIARY field to the specified name">;
3838

39-
def be8: F<"be8">, HelpText<"write a Big Endian ELF file using BE8 format (AArch32 only)">;
40-
4139
def Bno_symbolic: F<"Bno-symbolic">, HelpText<"Don't bind default visibility defined symbols locally for -shared (default)">;
4240

4341
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind default visibility defined symbols locally for -shared">;

lld/ELF/OutputSections.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,6 @@ void OutputSection::writeTo(uint8_t *buf, parallel::TaskGroup &tg) {
496496
else
497497
isec->writeTo<ELFT>(buf + isec->outSecOff);
498498

499-
// When in Arm BE8 mode, the linker has to convert the big-endian
500-
// instructions to little-endian, leaving the data big-endian.
501-
if (config->emachine == EM_ARM && !config->isLE && config->armBe8 &&
502-
(flags & SHF_EXECINSTR))
503-
convertArmInstructionstoBE8(isec, buf + isec->outSecOff);
504-
505499
// Fill gaps between sections.
506500
if (nonZeroFiller) {
507501
uint8_t *start = buf + isec->outSecOff + isec->getSize();

lld/ELF/SyntheticSections.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,6 @@ Defined *elf::addSyntheticLocal(StringRef name, uint8_t type, uint64_t value,
271271
value, size, &section);
272272
if (in.symTab)
273273
in.symTab->addSymbol(s);
274-
275-
if (config->emachine == EM_ARM && !config->isLE && config->armBe8 &&
276-
(section.flags & SHF_EXECINSTR))
277-
// Adding Linker generated mapping symbols to the arm specific mapping
278-
// symbols list.
279-
addArmSyntheticSectionMappingSymbol(s);
280-
281274
return s;
282275
}
283276

lld/ELF/Target.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,6 @@ uint64_t getPPC64TocBase();
224224
uint64_t getAArch64Page(uint64_t expr);
225225
void riscvFinalizeRelax(int passes);
226226
void mergeRISCVAttributesSections();
227-
void addArmInputSectionMappingSymbols();
228-
void addArmSyntheticSectionMappingSymbol(Defined *);
229-
void sortArmMappingSymbols();
230-
void convertArmInstructionstoBE8(InputSection *sec, uint8_t *buf);
231227

232228
LLVM_LIBRARY_VISIBILITY extern const TargetInfo *target;
233229
TargetInfo *getTarget();

lld/ELF/Thunks.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,7 @@ void ThumbV6MABSLongThunk::addSymbols(ThunkSection &isec) {
754754
addSymbol(saver().save("__Thumbv6MABSLongThunk_" + destination.getName()),
755755
STT_FUNC, 1, isec);
756756
addSymbol("$t", STT_NOTYPE, 0, isec);
757-
if (!getMayUseShortThunk())
758-
addSymbol("$d", STT_NOTYPE, 8, isec);
757+
addSymbol("$d", STT_NOTYPE, 8, isec);
759758
}
760759

761760
void ThumbV6MABSXOLongThunk::writeLong(uint8_t *buf) {
@@ -806,8 +805,7 @@ void ThumbV6MPILongThunk::addSymbols(ThunkSection &isec) {
806805
addSymbol(saver().save("__Thumbv6MPILongThunk_" + destination.getName()),
807806
STT_FUNC, 1, isec);
808807
addSymbol("$t", STT_NOTYPE, 0, isec);
809-
if (!getMayUseShortThunk())
810-
addSymbol("$d", STT_NOTYPE, 12, isec);
808+
addSymbol("$d", STT_NOTYPE, 12, isec);
811809
}
812810

813811
void ARMV5LongLdrPcThunk::writeLong(uint8_t *buf) {
@@ -820,8 +818,7 @@ void ARMV5LongLdrPcThunk::addSymbols(ThunkSection &isec) {
820818
addSymbol(saver().save("__ARMv5LongLdrPcThunk_" + destination.getName()),
821819
STT_FUNC, 0, isec);
822820
addSymbol("$a", STT_NOTYPE, 0, isec);
823-
if (!getMayUseShortThunk())
824-
addSymbol("$d", STT_NOTYPE, 4, isec);
821+
addSymbol("$d", STT_NOTYPE, 4, isec);
825822
}
826823

827824
void ARMV4ABSLongBXThunk::writeLong(uint8_t *buf) {
@@ -835,8 +832,7 @@ void ARMV4ABSLongBXThunk::addSymbols(ThunkSection &isec) {
835832
addSymbol(saver().save("__ARMv4ABSLongBXThunk_" + destination.getName()),
836833
STT_FUNC, 0, isec);
837834
addSymbol("$a", STT_NOTYPE, 0, isec);
838-
if (!getMayUseShortThunk())
839-
addSymbol("$d", STT_NOTYPE, 8, isec);
835+
addSymbol("$d", STT_NOTYPE, 8, isec);
840836
}
841837

842838
void ThumbV4ABSLongBXThunk::writeLong(uint8_t *buf) {
@@ -852,8 +848,7 @@ void ThumbV4ABSLongBXThunk::addSymbols(ThunkSection &isec) {
852848
STT_FUNC, 1, isec);
853849
addSymbol("$t", STT_NOTYPE, 0, isec);
854850
addSymbol("$a", STT_NOTYPE, 4, isec);
855-
if (!getMayUseShortThunk())
856-
addSymbol("$d", STT_NOTYPE, 8, isec);
851+
addSymbol("$d", STT_NOTYPE, 8, isec);
857852
}
858853

859854
void ThumbV4ABSLongThunk::writeLong(uint8_t *buf) {
@@ -870,8 +865,7 @@ void ThumbV4ABSLongThunk::addSymbols(ThunkSection &isec) {
870865
STT_FUNC, 1, isec);
871866
addSymbol("$t", STT_NOTYPE, 0, isec);
872867
addSymbol("$a", STT_NOTYPE, 4, isec);
873-
if (!getMayUseShortThunk())
874-
addSymbol("$d", STT_NOTYPE, 12, isec);
868+
addSymbol("$d", STT_NOTYPE, 12, isec);
875869
}
876870

877871
void ARMV4PILongBXThunk::writeLong(uint8_t *buf) {
@@ -888,8 +882,7 @@ void ARMV4PILongBXThunk::addSymbols(ThunkSection &isec) {
888882
addSymbol(saver().save("__ARMv4PILongBXThunk_" + destination.getName()),
889883
STT_FUNC, 0, isec);
890884
addSymbol("$a", STT_NOTYPE, 0, isec);
891-
if (!getMayUseShortThunk())
892-
addSymbol("$d", STT_NOTYPE, 12, isec);
885+
addSymbol("$d", STT_NOTYPE, 12, isec);
893886
}
894887

895888
void ARMV4PILongThunk::writeLong(uint8_t *buf) {
@@ -905,8 +898,7 @@ void ARMV4PILongThunk::addSymbols(ThunkSection &isec) {
905898
addSymbol(saver().save("__ARMv4PILongThunk_" + destination.getName()),
906899
STT_FUNC, 0, isec);
907900
addSymbol("$a", STT_NOTYPE, 0, isec);
908-
if (!getMayUseShortThunk())
909-
addSymbol("$d", STT_NOTYPE, 8, isec);
901+
addSymbol("$d", STT_NOTYPE, 8, isec);
910902
}
911903

912904
void ThumbV4PILongBXThunk::writeLong(uint8_t *buf) {
@@ -925,8 +917,7 @@ void ThumbV4PILongBXThunk::addSymbols(ThunkSection &isec) {
925917
STT_FUNC, 1, isec);
926918
addSymbol("$t", STT_NOTYPE, 0, isec);
927919
addSymbol("$a", STT_NOTYPE, 4, isec);
928-
if (!getMayUseShortThunk())
929-
addSymbol("$d", STT_NOTYPE, 12, isec);
920+
addSymbol("$d", STT_NOTYPE, 12, isec);
930921
}
931922

932923
void ThumbV4PILongThunk::writeLong(uint8_t *buf) {
@@ -946,8 +937,7 @@ void ThumbV4PILongThunk::addSymbols(ThunkSection &isec) {
946937
STT_FUNC, 1, isec);
947938
addSymbol("$t", STT_NOTYPE, 0, isec);
948939
addSymbol("$a", STT_NOTYPE, 4, isec);
949-
if (!getMayUseShortThunk())
950-
addSymbol("$d", STT_NOTYPE, 16, isec);
940+
addSymbol("$d", STT_NOTYPE, 16, isec);
951941
}
952942

953943
// Use the long jump which covers a range up to 8MiB.

lld/ELF/Writer.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,11 +2149,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
21492149
sec->finalize();
21502150

21512151
script->checkMemoryRegions();
2152-
2153-
if (config->emachine == EM_ARM && !config->isLE && config->armBe8) {
2154-
addArmInputSectionMappingSymbols();
2155-
sortArmMappingSymbols();
2156-
}
21572152
}
21582153

21592154
// Ensure data sections are not mixed with executable sections when

lld/docs/ld.lld.1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ Bind default visibility defined function symbols locally for
8888
.It Fl Bsymbolic-non-weak-functions
8989
Bind default visibility defined STB_GLOBAL function symbols locally for
9090
.Fl shared.
91-
.It Fl --be8
92-
Write a Big Endian ELF File using BE8 format(AArch32 only)
9391
.It Fl -build-id Ns = Ns Ar value
9492
Generate a build ID note.
9593
.Ar value

lld/test/ELF/arm-bl-v6.s

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
// RUN: llvm-objdump --no-print-imm-hex -d --triple=armv6eb-none-linux-gnueabi --start-address=0x22100c --stop-address=0x221014 %t2 | FileCheck --check-prefix=CHECK-ARM2-EB %s
1414
// RUN: llvm-objdump --no-print-imm-hex -d --triple=thumbv6eb-none-linux-gnueabi %t2 --start-address=0x622000 --stop-address=0x622002 | FileCheck --check-prefix=CHECK-THUMB2 %s
1515

16-
// RUN: ld.lld --be8 %t -o %t2
17-
// RUN: llvm-objdump --no-print-imm-hex -d --triple=armv6eb-none-linux-gnueabi --start-address=0x21000 --stop-address=0x21008 %t2 | FileCheck --check-prefix=CHECK-ARM1 %s
18-
// RUN: llvm-objdump --no-print-imm-hex -d --triple=thumbv6eb-none-linux-gnueabi %t2 --start-address=0x21008 --stop-address=0x2100c | FileCheck --check-prefix=CHECK-THUMB1 %s
19-
// RUN: llvm-objdump --no-print-imm-hex -d --triple=armv6eb-none-linux-gnueabi --start-address=0x22100c --stop-address=0x221014 %t2 | FileCheck --check-prefix=CHECK-ARM2-EB %s
20-
// RUN: llvm-objdump --no-print-imm-hex -d --triple=thumbv6eb-none-linux-gnueabi %t2 --start-address=0x622000 --stop-address=0x622002 | FileCheck --check-prefix=CHECK-THUMB2 %s
21-
2216
/// On Arm v6 the range of a Thumb BL instruction is only 4 megabytes as the
2317
/// extended range encoding is not supported. The following example has a Thumb
2418
/// BL that is out of range on ARM v6 and requires a range extension thunk.

lld/test/ELF/arm-data-relocs.s

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
// RUN: ld.lld %t.be.o %t256.be.o -o %t.be
1010
// RUN: llvm-objdump -s %t.be | FileCheck %s --check-prefixes=CHECK,BE
1111

12-
// RUN: ld.lld --be8 %t.be.o %t256.be.o -o %t.be8
13-
// RUN: llvm-objdump -s %t.be8 | FileCheck %s --check-prefixes=CHECK,BE
14-
1512
.globl _start
1613
_start:
1714
.section .R_ARM_ABS, "ax","progbits"

lld/test/ELF/arm-exidx-emit-relocs.s

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
// RUN: llvm-objdump -s --triple=armv7aeb-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EB %s
1010
// RUN: llvm-readelf --relocs %t2 | FileCheck -check-prefix=CHECK-RELOCS %s
1111

12-
// RUN: ld.lld --be8 --emit-relocs %t -o %t2
13-
// RUN: llvm-objdump -s --triple=armv7aeb-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EB %s
14-
// RUN: llvm-readelf --relocs %t2 | FileCheck -check-prefix=CHECK-RELOCS %s
15-
1612
/// LLD does not support --emit-relocs for .ARM.exidx sections as the relocations
1713
/// from synthetic table entries won't be represented. Given the known use cases
1814
/// of --emit-relocs, relocating kernels, and binary analysis, the former doesn't

lld/test/ELF/arm-exidx-relocatable.s

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
// Check that relocatable link maintains SHF_LINK_ORDER for big endian
1111
// RUN: ld.lld -r %t %tcantunwind -o %t4
1212
// RUN: llvm-readobj -S %t4 | FileCheck %s
13-
// RUN: ld.lld --be8 -r %t %tcantunwind -o %t4
14-
// RUN: llvm-readobj -S %t4 | FileCheck %s
1513

1614
// Each assembler created .ARM.exidx section has the SHF_LINK_ORDER flag set
1715
// with the sh_link containing the section index of the executable section

lld/test/ELF/arm-exidx-sentinel-norelocatable.s

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// RUN: llvm-mc %s -triple=armv7eb-unknown-linux-gnueabi -mcpu=cortex-a8 -filetype=obj -o %t.o
77
// RUN: ld.lld -r %t.o -o %t
88
// RUN: llvm-readobj -S %t | FileCheck %s
9-
// RUN: ld.lld --be8 -r %t.o -o %t
10-
// RUN: llvm-readobj -S %t | FileCheck %s
119

1210
// Check that when doing a relocatable link we don't add a terminating entry
1311
// to the .ARM.exidx section

lld/test/ELF/arm-header.s

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
# RUN: ld.lld %t.o -o %t1
44
# RUN: llvm-readobj -h %t1 | FileCheck %s
55

6-
# RUN: llvm-mc -filetype=obj -triple=armv7aeb-none-linux-gnueabi -mcpu=cortex-a8 %s -o %t.o
7-
# RUN: ld.lld --be8 %t.o -o %t1
8-
# RUN: llvm-readobj -h %t1 | FileCheck -check-prefix=CHECK-EB %s
9-
106
# CHECK: Format: elf32-bigarm
117

128
# CHECK: ElfHeader {
@@ -28,23 +24,3 @@
2824

2925
# CHECK-NOT: 0x800000
3026

31-
# CHECK-EB: Format: elf32-bigarm
32-
33-
# CHECK-EB: ElfHeader {
34-
# CHECK-EB-NEXT: Ident {
35-
# CHECK-EB-NEXT: Magic: (7F 45 4C 46)
36-
# CHECK-EB-NEXT: Class: 32-bit (0x1)
37-
# CHECK-EB-NEXT: DataEncoding: BigEndian (0x2)
38-
# CHECK-EB-NEXT: FileVersion: 1
39-
# CHECK-EB-NEXT: OS/ABI: SystemV (0x0)
40-
# CHECK-EB-NEXT: ABIVersion: 0
41-
# CHECK-EB-NEXT: Unused: (00 00 00 00 00 00 00)
42-
# CHECK-EB-NEXT: }
43-
44-
# CHECK-EB: Flags [ (0x5800200)
45-
# CHECK-EB-NEXT: 0x200
46-
# CHECK-EB-NEXT: 0x800000
47-
# CHECK-EB-NEXT: 0x1000000
48-
# CHECK-EB-NEXT: 0x4000000
49-
# CHECK-EB-NEXT: ]
50-

lld/test/ELF/arm-mov-relocs.s

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
// RUN: ld.lld %t3 -o %t4
1414
// RUN: llvm-objdump --no-print-imm-hex -d %t4 --triple=thumbv7aeb-unknown-linux-gnueabi --no-show-raw-insn | FileCheck %s
1515

16-
// RUN: ld.lld --be8 %t -o %t2
17-
// RUN: llvm-objdump --no-print-imm-hex -d %t2 --triple=armv7aeb-unknown-linux-gnueabi --no-show-raw-insn | FileCheck %s
18-
// RUN: ld.lld --be8 %t3 -o %t4
19-
// RUN: llvm-objdump --no-print-imm-hex -d %t4 --triple=thumbv7aeb-unknown-linux-gnueabi --no-show-raw-insn | FileCheck %s
20-
2116
/// Test the following relocation pairs:
2217
/// * R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS
2318
/// * R_ARM_MOVW_PREL_NC and R_ARM_MOVT_PREL

0 commit comments

Comments
 (0)