diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index e1e99556ec7b06..3d1e8e8a7f5bdc 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -91,15 +91,15 @@ TargetInfo *getTarget() { } template static ErrorPlace getErrPlace(const uint8_t *loc) { - if (!Out::bufferStart) - return {}; - for (InputSectionBase *d : inputSections) { auto *isec = cast(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 <= loc && loc < isecLoc + isec->getSize()) return {isec, isec->template getLocation(loc - isecLoc) + ": "}; } diff --git a/lld/test/ELF/mips-jalr-non-functions.s b/lld/test/ELF/mips-jalr-non-functions.s index 410b742c3e6f6e..cdb60cd39e8391 100644 --- a/lld/test/ELF/mips-jalr-non-functions.s +++ b/lld/test/ELF/mips-jalr-non-functions.s @@ -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: