[PATCH] D55118: [ELF] - Report an error if empty sections are referenced in LOADADDR/ADDR commands.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 30 05:31:34 PST 2018
grimar updated this revision to Diff 176099.
grimar marked an inline comment as done.
grimar added a comment.
- Fixed test case.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55118/new/
https://reviews.llvm.org/D55118
Files:
ELF/ScriptParser.cpp
test/ELF/linkerscript/empty-sections-expressions.test
Index: test/ELF/linkerscript/empty-sections-expressions.test
===================================================================
--- test/ELF/linkerscript/empty-sections-expressions.test
+++ test/ELF/linkerscript/empty-sections-expressions.test
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: echo ".text; nop; .data; .byte 0" \
+# RUN: | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
+# RUN: not ld.lld -o %t --script %s %t.o 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}.test:10: reference to removed section '.empty' not allowed
+
+SECTIONS {
+ . = 0x00080000;
+ .empty : { *(.empty ) }
+ .text : AT(LOADADDR (.empty)) { *(.text) }
+ .data : AT(ADDR (.empty)) { *(.data) }
+}
Index: ELF/ScriptParser.cpp
===================================================================
--- ELF/ScriptParser.cpp
+++ ELF/ScriptParser.cpp
@@ -1121,8 +1121,14 @@
}
static void checkIfExists(OutputSection *Cmd, StringRef Location) {
- if (Cmd->Location.empty() && Script->ErrorOnMissingSection)
+ if (!Script->ErrorOnMissingSection)
+ return;
+
+ if (Cmd->Location.empty())
error(Location + ": undefined section " + Cmd->Name);
+ else if (!Cmd->Live)
+ error(Cmd->Location + ": reference to removed section '" + Cmd->Name +
+ "' not allowed");
}
Expr ScriptParser::readPrimary() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55118.176099.patch
Type: text/x-patch
Size: 1309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181130/206146db/attachment.bin>
More information about the llvm-commits
mailing list