[lld] r295040 - [ELF][MIPS] Use `InputSectionBase::getOutputSection()` to access output sections from the `MipsGotSection`
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 01:56:16 PST 2017
Author: atanasyan
Date: Tue Feb 14 03:56:16 2017
New Revision: 295040
URL: http://llvm.org/viewvc/llvm-project?rev=295040&view=rev
Log:
[ELF][MIPS] Use `InputSectionBase::getOutputSection()` to access output sections from the `MipsGotSection`
Follow-up to r294005. This patch restores handling of MISP GOT
relocations against merge sections.
Added:
lld/trunk/test/ELF/mips-got-string.s
Modified:
lld/trunk/ELF/SyntheticSections.cpp
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=295040&r1=295039&r2=295040&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Feb 14 03:56:16 2017
@@ -493,7 +493,8 @@ void MipsGotSection<ELFT>::addEntry(Symb
// sections referenced by GOT relocations. Then later in the `finalize`
// method calculate number of "pages" required to cover all saved output
// section and allocate appropriate number of GOT entries.
- PageIndexMap.insert({cast<DefinedRegular<ELFT>>(&Sym)->Section->OutSec, 0});
+ auto *DefSym = cast<DefinedRegular<ELFT>>(&Sym);
+ PageIndexMap.insert({DefSym->Section->getOutputSection(), 0});
return;
}
if (Sym.isTls()) {
@@ -564,7 +565,7 @@ typename MipsGotSection<ELFT>::uintX_t
MipsGotSection<ELFT>::getPageEntryOffset(const SymbolBody &B,
uintX_t Addend) const {
const OutputSectionBase *OutSec =
- cast<DefinedRegular<ELFT>>(&B)->Section->OutSec;
+ cast<DefinedRegular<ELFT>>(&B)->Section->getOutputSection();
uintX_t SecAddr = getMipsPageAddr(OutSec->Addr);
uintX_t SymAddr = getMipsPageAddr(B.getVA<ELFT>(Addend));
uintX_t Index = PageIndexMap.lookup(OutSec) + (SymAddr - SecAddr) / 0xffff;
Added: lld/trunk/test/ELF/mips-got-string.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-got-string.s?rev=295040&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-got-string.s (added)
+++ lld/trunk/test/ELF/mips-got-string.s Tue Feb 14 03:56:16 2017
@@ -0,0 +1,28 @@
+# Check R_MIPS_GOT16 relocation against merge section.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -o %t.o %s
+# RUN: ld.lld -shared -o %t.so %t.o
+# RUN: llvm-readobj -t -mips-plt-got %t.so | FileCheck %s
+
+# REQUIRES: mips
+
+# CHECK: Symbol {
+# CHECK: Name: $.str
+# CHECK-NEXT: Value: 0xF4
+# CHECK: }
+
+# CHECK: Local entries [
+# CHECK-NEXT: Entry {
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Access: -32744
+# CHECK-NEXT: Initial: 0x0
+# CHECK: }
+# CHECK: ]
+
+ .text
+ lw $t9, %got($.str)($gp)
+ addiu $a0, $t9, %lo($.str)
+
+ .section .rodata.str,"aMS", at progbits,1
+$.str:
+ .asciz "foo"
More information about the llvm-commits
mailing list