mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 13:00:26 +02:00
refactor linker to lay out ELF files and memory in the same way
* module/system/vm/linker.scm (make-linker-object): (linker-object-section-symbol): (linker-object-symbols*): Create a symbol to the start of a linker object. Hide it from the external linker-object-symbols* accessor. (segment-kind, count-segments): Sections without SHF_ALLOC don't get segments. (collate-objects-into-segments): Allow for #f segment types. If two sections have the same type and flags, leave them in the same order. (align): Allow for 0 alignment. (add-elf-objects): New helper: puts the ELF data structures (header, segment table, and section table) in sections of their own. This lends a nice clarity and conceptual unity to the linker. (relocate-section-header, allocate-segment): Lay out segments with congruent, contiguous addresses, so that we can just mmap the file and if debugging sections that are not in segments are present, they can be lazily paged in if needed by the kernel's VM system. (link-elf): Refactor to use the new interfaces. * test-suite/tests/linker.test: Update to expect the additional sections for the header and section table.
This commit is contained in:
parent
51611a92f4
commit
d4da9ba9c0
2 changed files with 357 additions and 169 deletions
|
@ -75,8 +75,9 @@
|
|||
(set! elf (parse-elf bytes))
|
||||
(elf? elf)))
|
||||
|
||||
;; 3 sections: the initial NULL section, .foo, and .shstrtab.
|
||||
(pass-if-equal 3 (elf-shnum elf))
|
||||
;; 5 sections: the initial NULL section, .foo, .shstrtab, the initial
|
||||
;; header with segment table, and the section table.
|
||||
(pass-if-equal 5 (elf-shnum elf))
|
||||
|
||||
(pass-if ".foo section checks out"
|
||||
(let ((sec (assoc-ref (elf-sections-by-name elf) ".foo")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue