[PATCH] D154665: fixed invalid symbol handling in ELFObjectFile::getSymbolName
Dayann D'almeida via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 11 16:34:04 PDT 2023
JestrTulip updated this revision to Diff 539334.
JestrTulip added a comment.
feedback
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154665/new/
https://reviews.llvm.org/D154665
Files:
llvm/include/llvm/Object/ELFObjectFile.h
llvm/test/tools/llvm-objdump/ELF/section-symbols.test
Index: llvm/test/tools/llvm-objdump/ELF/section-symbols.test
===================================================================
--- llvm/test/tools/llvm-objdump/ELF/section-symbols.test
+++ llvm/test/tools/llvm-objdump/ELF/section-symbols.test
@@ -19,6 +19,11 @@
# CHECK-NEXT: 00000003 R_X86_64_NONE {{$}}
# CHECK-NEXT: 00000004 R_X86_64_NONE {{$}}
+## Test that we consume an error in ELFObjectFile<ELFT>::getSectionName when disassembling.
+# RUN: llvm-objdump -d --syms %t1 2>&1 | \
+# RUN: FileCheck %s -DFILE=%t1 --check-prefix=CHECK-DISAS
+# CHECK-DISAS: warning: '[[FILE]]': invalid section index: 67
+
--- !ELF
FileHeader:
Class: ELFCLASS32
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -530,10 +530,10 @@
// If the symbol name is empty use the section name.
if ((*SymOrErr)->getType() == ELF::STT_SECTION) {
- if (Expected<section_iterator> SecOrErr = getSymbolSection(Sym)) {
- consumeError(Name.takeError());
+ Expected<section_iterator> SecOrErr = getSymbolSection(Sym);
+ if (SecOrErr)
return (*SecOrErr)->getName();
- }
+ return SecOrErr.takeError();
}
return Name;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154665.539334.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230711/e8b85da4/attachment.bin>
More information about the llvm-commits
mailing list