Skip to content

Commit 6eeb6ee

Browse files
committed
Optimize dynamic-section.test and code style.
Signed-off-by: Ruoyu Qiu <[email protected]>
1 parent a8107b3 commit 6eeb6ee

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

llvm/test/tools/llvm-objdump/ELF/dynamic-section.test

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,10 @@ Sections:
474474
# RUN: yaml2obj --docnum=5 %s -o %t5
475475
# RUN: llvm-objdump -p %t5 2>&1 | FileCheck %s --strict-whitespace -DFILE=%t5 --check-prefix=WARN
476476

477-
# WARN: Program Header:
478-
# WARN: LOAD off 0x00000000000000b0 vaddr 0x0000000000001000 paddr 0x0000000000001000 align 2**0
479-
# WARN: filesz 0x0000000000000050 memsz 0x0000000000000050 flags ---
480-
# WARN: DYNAMIC off 0x00000000000000c0 vaddr 0x000000000000101d paddr 0x000000000000101d align 2**0
481-
# WARN: filesz 0x0000000000000040 memsz 0x0000000000000040 flags ---
482477
# WARN: Dynamic Section:
483478
# WARN: warning: '[[FILE]]': invalid string table offset
484-
# WARN: NEEDED 0x0000000000000011
479+
# WARN: NEEDED 0x0000000000000010
480+
# WARN: NEEDED
485481
# WARN: STRTAB 0x0000000000001000
486482
# WARN: STRSZ 0x0000000000000010
487483

@@ -496,12 +492,13 @@ Sections:
496492
Type: SHT_STRTAB
497493
Address: 0x1000
498494
Size: 0x10
499-
Content: "004400550066007700"
500495
- Name: .dynamic
501496
Type: SHT_DYNAMIC
502497
Entries:
503498
- Tag: DT_NEEDED
504-
Value: 0x11
499+
Value: 0x10
500+
- Tag: DT_NEEDED
501+
Value: 0x0F
505502
- Tag: DT_STRTAB
506503
Value: 0x1000
507504
- Tag: DT_STRSZ
@@ -514,6 +511,5 @@ ProgramHeaders:
514511
FirstSec: .dynstr
515512
LastSec: .dynamic
516513
- Type: PT_DYNAMIC
517-
VAddr: 0x101D
518514
FirstSec: .dynamic
519515
LastSec: .dynamic

llvm/tools/llvm-objdump/ELFDump.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ static Expected<StringRef> getDynamicStrTab(const ELFFile<ELFT> &Elf) {
7272
return MappedAddrOrError.takeError();
7373
MappedAddr = *MappedAddrOrError;
7474
}
75-
if (Dyn.d_tag == ELF::DT_STRSZ) {
75+
if (Dyn.d_tag == ELF::DT_STRSZ)
7676
StringTableSize = Dyn.getVal();
77-
}
7877
}
7978
if (MappedAddr && StringTableSize)
8079
return StringRef(reinterpret_cast<const char *>(MappedAddr),
8180
StringTableSize);
8281

83-
// If the dynamic segment is not present, we fall back on the sections.
82+
// If the dynamic segment is not present, or is missing the important tags, we
83+
// fall back on the sections.
8484
auto SectionsOrError = Elf.sections();
8585
if (!SectionsOrError)
8686
return SectionsOrError.takeError();

0 commit comments

Comments
 (0)