forked from OSchip/llvm-project
Re-apply "[ELF] Allow getErrPlace() to work before Out::bufferStart is set"
This time with a fix for the UBSAN failure. Differential Revision: https://reviews.llvm.org/D70659
This commit is contained in:
parent
4e003aad42
commit
1444e6e2e6
|
@ -28,6 +28,7 @@
|
|||
#include "OutputSections.h"
|
||||
#include "SymbolTable.h"
|
||||
#include "Symbols.h"
|
||||
#include "SyntheticSections.h"
|
||||
#include "lld/Common/ErrorHandler.h"
|
||||
#include "llvm/Object/ELF.h"
|
||||
|
||||
|
@ -91,15 +92,20 @@ TargetInfo *getTarget() {
|
|||
}
|
||||
|
||||
template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) {
|
||||
if (!Out::bufferStart)
|
||||
return {};
|
||||
|
||||
assert(loc != nullptr);
|
||||
for (InputSectionBase *d : inputSections) {
|
||||
auto *isec = cast<InputSection>(d);
|
||||
if (!isec->getParent())
|
||||
continue;
|
||||
|
||||
uint8_t *isecLoc = Out::bufferStart + isec->getParent()->offset + isec->outSecOff;
|
||||
const uint8_t *isecLoc =
|
||||
Out::bufferStart
|
||||
? (Out::bufferStart + isec->getParent()->offset + isec->outSecOff)
|
||||
: isec->data().data();
|
||||
if (isecLoc == nullptr) {
|
||||
assert(isa<SyntheticSection>(isec) && "No data but not synthetic?");
|
||||
continue;
|
||||
}
|
||||
if (isecLoc <= loc && loc < isecLoc + isec->getSize())
|
||||
return {isec, isec->template getLocation<ELFT>(loc - isecLoc) + ": "};
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ test:
|
|||
.Ltmp1:
|
||||
jr $t9
|
||||
nop
|
||||
# WARNING-MESSAGE: warning: found R_MIPS_JALR relocation against non-function symbol tls_obj. This is invalid and most likely a compiler bug.
|
||||
# WARNING-MESSAGE: warning: {{.+}}.tmp.o:(.text+0x0): found R_MIPS_JALR relocation against non-function symbol tls_obj. This is invalid and most likely a compiler bug.
|
||||
|
||||
.reloc .Ltmp2, R_MIPS_JALR, reg_obj
|
||||
.Ltmp2:
|
||||
jr $t9
|
||||
nop
|
||||
# WARNING-MESSAGE: warning: found R_MIPS_JALR relocation against non-function symbol reg_obj. This is invalid and most likely a compiler bug.
|
||||
# WARNING-MESSAGE: warning: {{.+}}.tmp.o:(.text+0x8): found R_MIPS_JALR relocation against non-function symbol reg_obj. This is invalid and most likely a compiler bug.
|
||||
|
||||
.reloc .Ltmp3, R_MIPS_JALR, untyped
|
||||
.Ltmp3:
|
||||
|
|
Loading…
Reference in New Issue