[llvm] [Mips] Fix clang integrated assembler generates incorrect relocations… (PR #83115)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 00:06:00 PDT 2024
================
@@ -2920,11 +2922,45 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
(Res.getSymA()->getSymbol().isELF() &&
cast<MCSymbolELF>(Res.getSymA()->getSymbol()).getBinding() ==
ELF::STB_LOCAL);
+
// For O32, "$"-prefixed symbols are recognized as temporary while
// .L-prefixed symbols are not (PrivateGlobalPrefix is "$"). Recognize ".L"
// manually.
if (ABI.IsO32() && Res.getSymA()->getSymbol().getName().starts_with(".L"))
IsLocalSym = true;
+ else {
+ if (HasParseRdata == false) {
+ StringRef CurrentASMContent = StringRef(IDLoc.getPointer());
+
+ // Get local symbol name LocalSymbol from "la $number, localsymbolname\n
+ // ... "
+ size_t NewlineIndex = CurrentASMContent.find_first_of('\n');
+ size_t CommaIndex = CurrentASMContent.find_first_of(',');
+ size_t SymbolLength = NewlineIndex - CommaIndex - 2;
+ StringRef LocalSymbol =
+ CurrentASMContent.take_front(NewlineIndex).take_back(SymbolLength);
+
+ // Get and check if ".rdata" section exist.
+ size_t RdataIndex = CurrentASMContent.find(".rdata");
----------------
wzssyqa wrote:
`find` is not a good way here: you may meet some strange strings from user's asmcode, may be from comment?
```
# this is a comment about .rdata
```
https://github.com/llvm/llvm-project/pull/83115
More information about the llvm-commits
mailing list