forked from OSchip/llvm-project
[llvm-readelf]Print filename for multiple inputs and fix formatting regression
This patch addresses two closely related bugs: https://bugs.llvm.org/show_bug.cgi?id=42930 and https://bugs.llvm.org/show_bug.cgi?id=42931. GNU readelf prints the file name for every input unless there is only one input and that input is not an archive. This patch adds the printing for multiple inputs. A previous change did it for archives, but introduced a regression with GNU compatibility for single-output formatting, resulting in a spurious initial blank line. This is fixed in this patch too. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D65953 llvm-svn: 368435
This commit is contained in:
parent
1429b7ed9e
commit
be39e398e9
|
@ -20,7 +20,6 @@
|
|||
|
||||
# WARN-GNU-NOT: warning
|
||||
# WARN-GNU: warning: invalid section size (4) or entity size (16)
|
||||
# WARN-GNU-EMPTY:
|
||||
# WARN-GNU-NEXT: ELF Header:
|
||||
# WARN-GNU: Symbol table '.symtab' contains 1 entries:
|
||||
# WARN-GNU: 0:
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
## This test shows that the name of the file is printed under the right
|
||||
## circumstances and with the correct formatting for object inputs.
|
||||
|
||||
# RUN: yaml2obj %s -o %t1
|
||||
# RUN: cp %t1 %t2
|
||||
|
||||
## Show that the file name is not printed for a single input for GNU output.
|
||||
# RUN: llvm-readelf --file-headers %t1 \
|
||||
# RUN: | FileCheck %s --implicit-check-not=File: --check-prefix=GNU-SINGLE
|
||||
|
||||
## Show that the very first line of the output is the one with "ELF Header" on.
|
||||
# GNU-SINGLE: {{^}}
|
||||
# GNU-SINGLE-SAME: ELF Header:
|
||||
|
||||
## Show that the file names are printed for all inputs for GNU output.
|
||||
# RUN: llvm-readelf --file-headers %t1 %t2 \
|
||||
# RUN: | FileCheck %s --check-prefixes=NAME1,GNU,NAME2 -DFILE1=%t1 -DFILE2=%t2
|
||||
|
||||
## Show that the file name is printed for a single input for LLVM output.
|
||||
# RUN: llvm-readobj --file-headers %t1 | FileCheck %s --check-prefix=NAME1 -DFILE1=%t1
|
||||
|
||||
## Show that the file name is printed with correct spacing for multiple inputs
|
||||
## with LLVM output.
|
||||
# RUN: llvm-readobj --file-headers %t1 %t2 \
|
||||
# RUN: | FileCheck %s --check-prefixes=NAME1,LLVM,NAME2 -DFILE1=%t1 -DFILE2=%t2
|
||||
|
||||
## The very first line should be blank. CHECK-EMPTY isn't allowed on the first line.
|
||||
# NAME1: {{^$}}
|
||||
# NAME1-NEXT: {{^}}File: [[FILE1]]{{$}}
|
||||
|
||||
# GNU: Section header string table index:
|
||||
# LLVM: StringTableSectionIndex:
|
||||
# LLVM-NEXT: }
|
||||
# NAME2-EMPTY:
|
||||
# NAME2-NEXT: {{^}}File: [[FILE2]]{{$}}
|
||||
|
||||
--- !ELF
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_X86_64
|
|
@ -322,11 +322,13 @@ Sections:
|
|||
## tables.
|
||||
|
||||
# RUN: llvm-ar rc %t1.a %t01 %t02
|
||||
# RUN: llvm-readelf --stack-sizes %t01 %t02 | FileCheck %s --check-prefix=MULTIPLE
|
||||
# RUN: llvm-readelf --stack-sizes %t01 %t02 \
|
||||
# RUN: | FileCheck %s --check-prefixes=MULTIPLE,OBJECT -DFILE1=%t01 -DFILE2=%t02
|
||||
# RUN: llvm-readelf --stack-sizes %t1.a \
|
||||
# RUN: | FileCheck %s --check-prefix=MULTIPLE --check-prefix=ARCHIVE --strict-whitespace\
|
||||
# RUN: | FileCheck %s --check-prefixes=MULTIPLE,ARCHIVE --strict-whitespace\
|
||||
# RUN: --match-full-lines -DFILE=%t1.a
|
||||
|
||||
# OBJECT:File: [[FILE1]]
|
||||
# ARCHIVE:File: [[FILE]]({{.*01}})
|
||||
# MULTIPLE:Stack Sizes:
|
||||
# MULTIPLE-NEXT: Size Function
|
||||
|
@ -334,6 +336,7 @@ Sections:
|
|||
# MULTIPLE-NEXT: 32 referenced_via_section_bar
|
||||
# MULTIPLE-NEXT: 8 separate_text_section_baz
|
||||
# MULTIPLE-EMPTY:
|
||||
# OBJECT:File: [[FILE2]]
|
||||
# ARCHIVE:File: [[FILE]]({{.*02}})
|
||||
# MULTIPLE-EMPTY:
|
||||
# MULTIPLE-NEXT:Stack Sizes:
|
||||
|
|
|
@ -484,17 +484,17 @@ static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer,
|
|||
if (std::error_code EC = createDumper(Obj, Writer, Dumper))
|
||||
reportError(FileStr, EC);
|
||||
|
||||
if (opts::Output == opts::LLVM || opts::InputFilenames.size() > 1 || A) {
|
||||
Writer.startLine() << "\n";
|
||||
if (opts::Output == opts::LLVM) {
|
||||
Writer.printString("File", FileStr);
|
||||
}
|
||||
if (opts::Output == opts::LLVM) {
|
||||
Writer.printString("Format", Obj->getFileFormatName());
|
||||
Writer.printString("Arch", Triple::getArchTypeName(
|
||||
(llvm::Triple::ArchType)Obj->getArch()));
|
||||
Writer.printString("AddressSize",
|
||||
formatv("{0}bit", 8 * Obj->getBytesInAddress()));
|
||||
Dumper->printLoadName();
|
||||
} else if (opts::Output == opts::GNU && A) {
|
||||
Writer.printString("File", FileStr);
|
||||
}
|
||||
|
||||
if (opts::FileHeaders)
|
||||
|
|
Loading…
Reference in New Issue