-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SHT_LLVM_FUNC_MAP][ObjectYaml]Introduce function address map section and emit dynamic instruction count(ObjectYaml part) #124332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
2e0f4ff
d2b1895
5841112
cc11306
e8a1dce
d2d627e
970042e
3703e53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct me if I'm wrong, but shouldn't this be using the Elf_Addr type, since it's representing an address? They might amount to the same thing, but it conveys the meaning better. (NB: I haven't tested it, so this might not work as desired)
Suggested change
|
||||||
| SHeader.sh_size += sizeof(uintX_t); | ||||||
| Size += sizeof(uintX_t); | ||||||
| CBA.write<uint64_t>(E.DynamicInstCount, ELFT::Endianness); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the DynamicInstCount should be architecture-dependent type, so that on 32-bit architectures, it only takes up 4 bytes? There's probably an argument actually that it should always just be 4 bytes, since you'd be hard pressed to need more than what 4 bytes can represent in instruction counts. |
||||||
| SHeader.sh_size += 8; | ||||||
| Size += 8; | ||||||
|
|
||||||
| SHeader.sh_size += Size; | ||||||
| SHeader.sh_entsize = Size; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
|
|
@@ -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 | ||
|
|
@@ -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})}}'{{$}} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be tempted to explicitly check the expected 8 bytes here, to show that it's not producing garbage here. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size setting code in this loop could be dramatically simplified for now, now that we're using fixed size entries. Outside the loop, you could just do something like: