[PATCH] D74764: [yaml2obj][WIP] - Automatically assign VA for allocatable sections.
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 17:27:07 PST 2020
MaskRay added a comment.
I think this is the correct approach. It will definitely simplify tests.
Nit: in the description, use `sh_addr` instead of `VA` because `sh_addr` may be more familiar to readers.
================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:222
+ void assignSectionAddress(Elf_Shdr &SHeader, ELFYAML::Section* YAMLSec);
+
----------------
`Section *`
================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:397
+ LocationCounter += Header.sh_size;
+
----------------
Add a test that `ShSize` (overriding sh_size, usually used for abnormal values) does not affect `LocationCounter`.
================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:527
+
+ if (!(SHeader.sh_flags & ELF::SHF_ALLOC))
+ return;
----------------
Delete. I think non-SHF_ALLOC sections follow the same rule.
================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:531
+ LocationCounter =
+ alignTo(LocationCounter, SHeader.sh_addralign ? SHeader.sh_addralign : 1);
+ SHeader.sh_addr = LocationCounter;
----------------
getValueOr
================
Comment at: llvm/test/tools/yaml2obj/ELF/section-address-assign.yaml:31
+ Flags: [ SHF_ALLOC ]
+ Address: 0x1000
+ Size: 0x3
----------------
0x1000 is fine but probably not the best.
If .text.any.addr is included by a PT_LOAD, one will expect `sh_offset%p_align = sh_addr%p_align` (a PT_LOAD's p_align is usually 0x1000 (maxpagesize) on x86).
One approach is to specify sh_addralign and set sh_addr to sh_addralign plus a multiple of p_align.
```
Address: 0x1200
AddressAlign: 0x200
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74764/new/
https://reviews.llvm.org/D74764
More information about the llvm-commits
mailing list