Skip to content

Commit

Permalink
set entry size
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
wlei-llvm committed Feb 15, 2025
1 parent 970042e commit 3703e53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions llvm/lib/ObjectYAML/ELFEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1550,18 +1550,22 @@ void ELFState<ELFT>::writeSectionContent(Elf_Shdr &SHeader,
return;

for (const auto &[Idx, E] : llvm::enumerate(*Section.Entries)) {
unsigned Size = 0;
if (Section.Type == llvm::ELF::SHT_LLVM_FUNC_MAP) {
if (E.Version > 1)
WithColor::warning() << "unsupported SHT_LLVM_FUNC_MAP version: "
<< static_cast<int>(E.Version)
<< "; encoding using the most recent version";
CBA.write(E.Version);
SHeader.sh_size += 1;
Size += 1;
}
CBA.write<uintX_t>(E.Address, ELFT::Endianness);
SHeader.sh_size += sizeof(uintX_t);
Size += sizeof(uintX_t);
CBA.write<uint64_t>(E.DynamicInstCount, ELFT::Endianness);
SHeader.sh_size += 8;
Size += 8;

SHeader.sh_size += Size;
SHeader.sh_entsize = Size;
}
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/test/tools/obj2yaml/ELF/func-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# VALID-NEXT: Sections:
# VALID-NEXT: - Name: .llvm_func_map
# VALID-NEXT: Type: SHT_LLVM_FUNC_MAP
# VALID-NEXT: EntSize: 0x11
# VALID-NEXT: Entries:
# VALID-NEXT: - Version: 1
## The 'Address' field is omitted when it's zero.
Expand Down Expand Up @@ -82,12 +83,14 @@ Sections:
# MULTI-NEXT: Sections:
# MULTI-NEXT: - Name: .llvm_func_map
# MULTI-NEXT: Type: SHT_LLVM_FUNC_MAP
# MULTI-NEXT: EntSize: 0x11
# MULTI-NEXT: Entries:
# MULTI-NEXT: - Version: 1
# MULTI-NEXT: Address: 0x2
# MULTI-NEXT: DynInstCnt: 3
# MULTI-NEXT: - Name: '.llvm_func_map (1)'
# MULTI-NEXT: Type: SHT_LLVM_FUNC_MAP
# MULTI-NEXT: EntSize: 0x11
# MULTI-NEXT: Entries:
# MULTI-NEXT: - Version: 1
# MULTI-NEXT: Address: 0xA
Expand Down Expand Up @@ -127,4 +130,5 @@ Sections:
# INVALID-NEXT: Sections:
# INVALID-NEXT: - Name: .llvm_func_map
# INVALID-NEXT: Type: SHT_LLVM_FUNC_MAP
# INVALID-NEXT: EntSize: 0x11
# TRUNCATED-NEXT: Content: '{{([[:xdigit:]]{16})}}'{{$}}

0 comments on commit 3703e53

Please sign in to comment.