Skip to content

Commit 63adf07

Browse files
committed
ELFObjectWriter: Move Thumb-specific condition to ARMELFObjectWriter
1 parent 3910a2c commit 63adf07

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,13 +1298,6 @@ bool ELFObjectWriter::useSectionSymbol(const MCValue &Val,
12981298
return false;
12991299
}
13001300

1301-
// If the symbol is a thumb function the final relocation must set the lowest
1302-
// bit. With a symbol that is done by just having the symbol have that bit
1303-
// set, so we would lose the bit if we relocated with the section.
1304-
// FIXME: We could use the section but add the bit to the relocation value.
1305-
if (EMachine == ELF::EM_ARM && Asm->isThumbFunc(Sym))
1306-
return false;
1307-
13081301
return !TargetObjectWriter->needsRelocateWithSymbol(Val, *Sym, Type);
13091302
}
13101303

llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "MCTargetDesc/ARMMCExpr.h"
1111
#include "MCTargetDesc/ARMMCTargetDesc.h"
1212
#include "llvm/BinaryFormat/ELF.h"
13+
#include "llvm/MC/MCAssembler.h"
1314
#include "llvm/MC/MCContext.h"
1415
#include "llvm/MC/MCELFObjectWriter.h"
1516
#include "llvm/MC/MCExpr.h"
@@ -47,9 +48,16 @@ ARMELFObjectWriter::ARMELFObjectWriter(uint8_t OSABI)
4748
ELF::EM_ARM,
4849
/*HasRelocationAddend*/ false) {}
4950

50-
bool ARMELFObjectWriter::needsRelocateWithSymbol(const MCValue &,
51-
const MCSymbol &,
51+
bool ARMELFObjectWriter::needsRelocateWithSymbol(const MCValue &Val,
52+
const MCSymbol &Sym,
5253
unsigned Type) const {
54+
// If the symbol is a thumb function the final relocation must set the lowest
55+
// bit. With a symbol that is done by just having the symbol have that bit
56+
// set, so we would lose the bit if we relocated with the section.
57+
// We could use the section but add the bit to the relocation value.
58+
if (Asm->isThumbFunc(Val.getAddSym()))
59+
return true;
60+
5361
// FIXME: This is extremely conservative. This really needs to use an
5462
// explicit list with a clear explanation for why each realocation needs to
5563
// point to the symbol, not to the section.

0 commit comments

Comments
 (0)