diff options
| author | Vlad Tsyrklevich <vtsyrklevich@google.com> | 2019-12-13 09:43:51 -0800 |
|---|---|---|
| committer | Vlad Tsyrklevich <vtsyrklevich@google.com> | 2019-12-13 09:43:51 -0800 |
| commit | 17063abd1e7350c854681665d5f2510d532e821e (patch) | |
| tree | cb4915aec121420257a811123ed9748b655c028c | |
| parent | d53e61863d48a07ce285d5b0a36abc67583023bd (diff) | |
| download | bcm5719-llvm-17063abd1e7350c854681665d5f2510d532e821e.tar.gz bcm5719-llvm-17063abd1e7350c854681665d5f2510d532e821e.zip | |
Revert "[ELF] Allow getErrPlace() to work before Out::bufferStart is set"
This reverts commit 2bbd32f5e8f0f62d895966e2623d9bdb9778b50b, it was
causing UBSan failures like the following:
lld/ELF/Target.cpp:103:41: runtime error: applying non-zero offset 24 to null pointer
| -rw-r--r-- | lld/ELF/Target.cpp | 8 | ||||
| -rw-r--r-- | lld/test/ELF/mips-jalr-non-functions.s | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 3d1e8e8a7f5..e1e99556ec7 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -91,15 +91,15 @@ TargetInfo *getTarget() { } template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) { + if (!Out::bufferStart) + return {}; + for (InputSectionBase *d : inputSections) { auto *isec = cast<InputSection>(d); if (!isec->getParent()) continue; - const uint8_t *isecLoc = - Out::bufferStart - ? (Out::bufferStart + isec->getParent()->offset + isec->outSecOff) - : isec->data().data(); + uint8_t *isecLoc = Out::bufferStart + isec->getParent()->offset + isec->outSecOff; if (isecLoc <= loc && loc < isecLoc + isec->getSize()) return {isec, isec->template getLocation<ELFT>(loc - isecLoc) + ": "}; } diff --git a/lld/test/ELF/mips-jalr-non-functions.s b/lld/test/ELF/mips-jalr-non-functions.s index cdb60cd39e8..410b742c3e6 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: {{.+}}.tmp.o:(.text+0x0): found R_MIPS_JALR relocation against non-function symbol tls_obj. This is invalid and most likely a compiler bug. +# WARNING-MESSAGE: warning: 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: {{.+}}.tmp.o:(.text+0x8): found R_MIPS_JALR relocation against non-function symbol reg_obj. This is invalid and most likely a compiler bug. +# WARNING-MESSAGE: warning: 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: |

