1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[llvm-readelf/obj] - Stop using reportError when dumping notes.

This starts using `reportUniqueWarnings` instead of `reportError`
in the code that is responsible for dumping notes.

Differential revision: https://reviews.llvm.org/D92021
This commit is contained in:
Georgii Rymar 2020-11-24 14:54:48 +03:00
parent 3155b4b053
commit 193f2ca439
2 changed files with 68 additions and 20 deletions

View File

@ -113,10 +113,22 @@ ProgramHeaders:
## that goes past the end of file.
# RUN: yaml2obj --docnum=2 -DSHOFFSET=0xffff0000 %s -o %t2.so
# RUN: not llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1
# RUN: not llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1
# RUN: llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1-GNU
# RUN: llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s --check-prefix=ERR1-LLVM
# ERR1: error: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)
# ERR1-GNU: Displaying notes found in: .note
# ERR1-GNU-NEXT: Owner Data size Description
# ERR1-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)
# ERR1-GNU-NOT: {{.}}
# ERR1-LLVM: Notes [
# ERR1-LLVM-NEXT: NoteSection {
# ERR1-LLVM-NEXT: Name: .note
# ERR1-LLVM-NEXT: Offset: 0xFFFF0000
# ERR1-LLVM-NEXT: Size: 0x0
# ERR1-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0xffff0000) or size (0x0)
# ERR1-LLVM-NEXT: }
# ERR1-LLVM-NEXT: ]
--- !ELF
FileHeader:
@ -134,19 +146,43 @@ Sections:
## that goes past the end of file.
# RUN: yaml2obj --docnum=2 -DSHSIZE=0xffff0000 %s -o %t3.so
# RUN: not llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2
# RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2
# RUN: llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2-GNU
# RUN: llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s --check-prefix=ERR2-LLVM
# ERR2: error: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)
# ERR2-GNU: Displaying notes found in: .note
# ERR2-GNU-NEXT: Owner Data size Description
# ERR2-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)
# ERR2-GNU-NOT: {{.}}
# ERR2-LLVM: Notes [
# ERR2-LLVM-NEXT: NoteSection {
# ERR2-LLVM-NEXT: Name: .note
# ERR2-LLVM-NEXT: Offset: 0x40
# ERR2-LLVM-NEXT: Size: 0xFFFF0000
# ERR2-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the SHT_NOTE section with index 1: invalid offset (0x40) or size (0xffff0000)
# ERR2-LLVM-NEXT: }
# ERR2-LLVM-NEXT: ]
## Test tools report an error if a note program header has an invalid offset that
## goes past the end of file.
# RUN: yaml2obj --docnum=3 -DPHOFFSET=0xffff0000 %s -o %t4.so
# RUN: not llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3
# RUN: not llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3
# RUN: llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3-GNU
# RUN: llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s --check-prefix=ERR3-LLVM
# ERR3: error: '[[FILE]]': unable to read notes from the PT_NOTE segment: invalid offset (0xffff0000) or size (0x0)
# ERR3-GNU: Displaying notes found at file offset 0xffff0000 with length 0x00000000:
# ERR3-GNU-NEXT: Owner Data size Description
# ERR3-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 1: invalid offset (0xffff0000) or size (0x0)
# ERR3-GNU-NOT: {{.}}
# ERR3-LLVM: Notes [
# ERR3-LLVM-NEXT: NoteSection {
# ERR3-LLVM-NEXT: Name: <?>
# ERR3-LLVM-NEXT: Offset: 0xFFFF0000
# ERR3-LLVM-NEXT: Size: 0x0
# ERR3-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 1: invalid offset (0xffff0000) or size (0x0)
# ERR3-LLVM-NEXT: }
# ERR3-LLVM-NEXT: ]
--- !ELF
FileHeader:
@ -162,10 +198,22 @@ ProgramHeaders:
## goes past the end of file.
# RUN: yaml2obj --docnum=3 -DPHFILESIZE=0xffff0000 %s -o %t5.so
# RUN: not llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4
# RUN: not llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4
# RUN: llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4-GNU
# RUN: llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s --check-prefix=ERR4-LLVM
# ERR4: error: '[[FILE]]': unable to read notes from the PT_NOTE segment: invalid offset (0x0) or size (0xffff0000)
# ERR4-GNU: Displaying notes found at file offset 0x00000000 with length 0xffff0000:
# ERR4-GNU-NEXT: Owner Data size Description
# ERR4-GNU-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 1: invalid offset (0x0) or size (0xffff0000)
# ERR4-GNU-NOT: {{.}}
# ERR4-LLVM: Notes [
# ERR4-LLVM-NEXT: NoteSection {
# ERR4-LLVM-NEXT: Name: <?>
# ERR4-LLVM-NEXT: Offset: 0x0
# ERR4-LLVM-NEXT: Size: 0xFFFF0000
# ERR4-LLVM-NEXT: warning: '[[FILE]]': unable to read notes from the PT_NOTE segment with index 1: invalid offset (0x0) or size (0xffff0000)
# ERR4-LLVM-NEXT: }
# ERR4-LLVM-NEXT: ]
## Check we report a warning when we are unable to locate the PT_NOTE
## segment because of broken program headers.

View File

@ -5562,10 +5562,9 @@ static void printNotesHelper(
for (const typename ELFT::Note &Note : Obj.notes(S, Err))
ProcessNoteFn(Note);
if (Err)
reportError(createError("unable to read notes from the " +
describe(Obj, S) + ": " +
toString(std::move(Err))),
Dumper.getElfObject().getFileName());
Dumper.reportUniqueWarning(
createError("unable to read notes from the " + describe(Obj, S) +
": " + toString(std::move(Err))));
FinishNotesFn();
}
return;
@ -5579,7 +5578,9 @@ static void printNotesHelper(
return;
}
size_t I = 0;
for (const typename ELFT::Phdr &P : *PhdrsOrErr) {
++I;
if (P.p_type != PT_NOTE)
continue;
StartNotesFn(/*SecName=*/None, P.p_offset, P.p_filesz);
@ -5587,10 +5588,9 @@ static void printNotesHelper(
for (const typename ELFT::Note Note : Obj.notes(P, Err))
ProcessNoteFn(Note);
if (Err)
reportError(
createError("unable to read notes from the PT_NOTE segment: " +
toString(std::move(Err))),
Dumper.getElfObject().getFileName());
Dumper.reportUniqueWarning(createError(
"unable to read notes from the PT_NOTE segment with index " +
Twine(I) + ": " + toString(std::move(Err))));
FinishNotesFn();
}
}