[PATCH] D20688: [ELF][MIPS] Handle section symbol points to the .MIPS.options / .reginfo section
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 13:52:24 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270910: [ELF][MIPS] Handle section symbol points to the .MIPS.options / .reginfo section (authored by atanasyan).
Changed prior to commit:
http://reviews.llvm.org/D20688?vs=58682&id=58691#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20688
Files:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/ELF/Inputs/mips-options.o
lld/trunk/test/ELF/mips-options-r.test
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -67,8 +67,13 @@
case MipsReginfo:
case MipsOptions:
// MIPS .reginfo and .MIPS.options sections are consumed by the linker,
- // so they should never be copied to output.
- llvm_unreachable("MIPS reginfo/options section reached writeTo().");
+ // and the linker produces a single output section. It is possible that
+ // input files contain section symbol points to the corresponding input
+ // section. Redirect it to the produced output section.
+ if (Offset != 0)
+ fatal("Unsupported reference to the middle of '" + getSectionName() +
+ "' section");
+ return this->OutSec->getVA();
}
llvm_unreachable("invalid section kind");
}
Index: lld/trunk/ELF/OutputSections.cpp
===================================================================
--- lld/trunk/ELF/OutputSections.cpp
+++ lld/trunk/ELF/OutputSections.cpp
@@ -1582,6 +1582,7 @@
// Copy input object file's .reginfo gprmask to output.
auto *S = cast<MipsReginfoInputSection<ELFT>>(C);
GprMask |= S->Reginfo->ri_gprmask;
+ S->OutSec = this;
}
template <class ELFT>
@@ -1610,6 +1611,7 @@
auto *S = cast<MipsOptionsInputSection<ELFT>>(C);
if (S->Reginfo)
GprMask |= S->Reginfo->ri_gprmask;
+ S->OutSec = this;
}
namespace lld {
Index: lld/trunk/test/ELF/mips-options-r.test
===================================================================
--- lld/trunk/test/ELF/mips-options-r.test
+++ lld/trunk/test/ELF/mips-options-r.test
@@ -0,0 +1,19 @@
+# Check that if input file contains .MIPS.options section and symbol
+# points to the section and the linker generates a relocatable output,
+# LLD does not crash and write section symbols point to the output
+# .MIPS.options section.
+#
+# PR 27878
+#
+# Input object file created using the following script:
+# % cat t.s
+# .text
+# nop
+# % as -mabi=64 -mips64r2 t.s
+
+# RUN: ld.lld -r %p/Inputs/mips-options.o -o %t.o
+# RUN: llvm-readobj -t %t.o | FileCheck %s
+
+# REQUIRES: mips
+
+# CHECK: Section: .MIPS.options
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20688.58691.patch
Type: text/x-patch
Size: 2191 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160526/9b5f4b57/attachment.bin>
More information about the llvm-commits
mailing list