llvm.org GIT mirror llvm / e8ff062
Report an error on invalid sh_entsize. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241070 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
3 changed file(s) with 43 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
284284 }
285285
286286 const Elf_Sym *begin_dynamic_symbols() const {
287 if (DynSymRegion.Addr)
288 return reinterpret_cast(DynSymRegion.Addr);
289 return nullptr;
287 if (!DynSymRegion.Addr)
288 return nullptr;
289 if (DynSymRegion.EntSize != sizeof(Elf_Sym))
290 report_fatal_error("Invalid symbol size");
291 return reinterpret_cast(DynSymRegion.Addr);
290292 }
291293
292294 const Elf_Sym *end_dynamic_symbols() const {
293 if (DynSymRegion.Addr)
294 return reinterpret_cast(
295 ((const char *)DynSymRegion.Addr + DynSymRegion.Size));
296
297 return nullptr;
295 if (!DynSymRegion.Addr)
296 return nullptr;
297 return reinterpret_cast(
298 ((const char *)DynSymRegion.Addr + DynSymRegion.Size));
298299 }
299300
300301 Elf_Sym_Range dynamic_symbols() const {
765766 const typename ELFFile::Elf_Sym *ELFFile::begin_symbols() const {
766767 if (!dot_symtab_sec)
767768 return nullptr;
769 if (dot_symtab_sec->sh_entsize != sizeof(Elf_Sym))
770 report_fatal_error("Invalid symbol size");
768771 return reinterpret_cast(base() + dot_symtab_sec->sh_offset);
769772 }
770773
44
55 RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-non-null.elf 2>&1 | FileCheck --check-prefix=NON-NULL %s
66 NON-NULL: String table must end with a null terminator
7
8 Test the sh_entsize are invalid
9 RUN: llvm-readobj -s %p/Inputs/invalid-sh_entsize.elf | FileCheck --check-prefix=SECTION %s
10
11 SECTION: Name: .dynsym
12 SECTION-NEXT: Type: SHT_DYNSYM
13 SECTION-NEXT: Flags [
14 SECTION-NEXT: SHF_ALLOC
15 SECTION-NEXT: ]
16 SECTION-NEXT: Address:
17 SECTION-NEXT: Offset:
18 SECTION-NEXT: Size:
19 SECTION-NEXT: Link:
20 SECTION-NEXT: Info:
21 SECTION-NEXT: AddressAlignment:
22 SECTION-NEXT: EntrySize: 32
23
24 SECTION: Name: .symtab
25 SECTION-NEXT: Type: SHT_SYMTAB
26 SECTION-NEXT: Flags [
27 SECTION-NEXT: ]
28 SECTION-NEXT: Address:
29 SECTION-NEXT: Offset:
30 SECTION-NEXT: Size:
31 SECTION-NEXT: Link:
32 SECTION-NEXT: Info:
33 SECTION-NEXT: AddressAlignment:
34 SECTION-NEXT: EntrySize: 32
35
36 RUN: not llvm-readobj -t %p/Inputs/invalid-sh_entsize.elf 2>&1 | FileCheck --check-prefix=INVALID-SYM-SIZE %s
37 RUN: not llvm-readobj --dyn-symbols %p/Inputs/invalid-sh_entsize.elf 2>&1 | FileCheck --check-prefix=INVALID-SYM-SIZE %s
38 INVALID-SYM-SIZE: Invalid symbol size