diff options
Diffstat (limited to 'compiler/elf_builder.h')
-rw-r--r-- | compiler/elf_builder.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/elf_builder.h b/compiler/elf_builder.h index 46484b1cd6..3d24d19919 100644 --- a/compiler/elf_builder.h +++ b/compiler/elf_builder.h @@ -165,10 +165,15 @@ class ElfBuilder FINAL { } } - // Set desired allocation size for .bss section. - void SetSize(Elf_Word size) { - CHECK_EQ(header_.sh_type, (Elf_Word)SHT_NOBITS); + // Write this section as "NOBITS" section. (used for the .bss section) + // This means that the ELF file does not contain the initial data for this section + // and it will be zero-initialized when the ELF file is loaded in the running program. + void WriteNoBitsSection(Elf_Word size) { + DCHECK_NE(header_.sh_flags & SHF_ALLOC, 0u); + Start(); + header_.sh_type = SHT_NOBITS; header_.sh_size = size; + End(); } // This function always succeeds to simplify code. @@ -346,6 +351,12 @@ class ElfBuilder FINAL { other_sections_.push_back(std::move(s)); } + // Set where the next section will be allocated in the virtual address space. + void SetVirtualAddress(Elf_Addr address) { + DCHECK_GE(address, virtual_address_); + virtual_address_ = address; + } + void Start() { // Reserve space for ELF header and program headers. // We do not know the number of headers until later, so |