[PATCH] D66704: [ELF] Error if --strip-all and --emit-relocs are used together
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 24 06:30:59 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
--strip-all suppresses the creation of in.symtab
This can cause a null pointer dereference in OutputSection::finalize
// --emit-relocs => copyRelocs is true
if (!config->copyRelocs || (type != SHT_RELA && type != SHT_REL))
return;
...
link = in.symTab->getParent()->sectionIndex; // in.symTab is null
Let's just disallow the combination.
In some cases:
- ld.bfd: final link failed: invalid operation
- gold: internal error in set_no_output_symtab_entry, at ../../gold/object.h:1814
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D66704
Files:
ELF/Driver.cpp
test/ELF/strip-all.s
Index: test/ELF/strip-all.s
===================================================================
--- test/ELF/strip-all.s
+++ test/ELF/strip-all.s
@@ -21,6 +21,9 @@
#RUN: ld.lld %t.o -s -o %t1
#RUN: llvm-objdump -section-headers %t1 | FileCheck %s -check-prefix AFTER
+# RUN: not ld.lld %t.o --strip-all --emit-relocs -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
+# ERR: error: --strip-all and --emit-relocs may not be used together
+
# exits with return code 42 on linux
.globl _start
_start:
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -314,6 +314,9 @@
if (!config->relocatable && !config->defineCommon)
error("-no-define-common not supported in non relocatable output");
+ if (config->strip == StripPolicy::All && config->emitRelocs)
+ error("--strip-all and --emit-relocs may not be used together");
+
if (config->zText && config->zIfuncNoplt)
error("-z text and -z ifunc-noplt may not be used together");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66704.217019.patch
Type: text/x-patch
Size: 1034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190824/b096bd44/attachment.bin>
More information about the llvm-commits
mailing list