Bug 78871
Summary: | bfd/elf allows only 2 PT_LOAD segments/phdrs | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Need Real Name <bhavesh> | ||||||||
Component: | binutils | Assignee: | Jakub Jelinek <jakub> | ||||||||
Status: | CLOSED WONTFIX | QA Contact: | |||||||||
Severity: | high | Docs Contact: | |||||||||
Priority: | high | ||||||||||
Version: | 8.0 | CC: | mitr | ||||||||
Target Milestone: | --- | ||||||||||
Target Release: | --- | ||||||||||
Hardware: | i686 | ||||||||||
OS: | Linux | ||||||||||
Whiteboard: | |||||||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||||||
Doc Text: | Story Points: | --- | |||||||||
Clone Of: | Environment: | ||||||||||
Last Closed: | 2004-10-02 20:50:31 UTC | Type: | --- | ||||||||
Regression: | --- | Mount Type: | --- | ||||||||
Documentation: | --- | CRM: | |||||||||
Verified Versions: | Category: | --- | |||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||
Embargoed: | |||||||||||
Attachments: |
|
Description
Need Real Name
2002-12-02 16:35:34 UTC
Created attachment 87049 [details]
Source file to show bug
Created attachment 87051 [details]
Linker script that shows bug
Not going to happen. This is optimized for the common case. Your patch wastes 256 bytes at start of every single binary/library (on IA-32, more so on 64bit arches). If you need more than 2 PT_LOAD segments, then you just need to make sure you make more room for it in the linker script. E.g. by modifying the linker builtin script (ld --verbose), replacing /* Read-only sections, merged into text segment: */ . = 0x08048000 + SIZEOF_HEADERS; with /* Read-only sections, merged into text segment: */ . = 0x08048000 + SIZEOF_HEADERS + 256; (or how much room you want to reserve). Created attachment 87785 [details]
New patch
The workaround suggested by jakub doesn't work if a linker script is appended to the default linker script (no -T, just a linker script as an input file) However, here is an alternative fix that doesn't reserve additional space for program headers for every ELF binary generated. It only grows the program headers if it needs to due to a section definition that requires that a new PT_LOAD segment be created. Please apply elf.patch That doesn't work, at the time this routine is invoked, sections are already sized and thus you can't grow the space for phdrs. You can always tweak the defaut linker script, as in: gcc -Wl,--verbose 2>&1 | sed massage_the_script > prog.lds gcc ... -Wl,-T,prog.lds ... In my case, I already have an elaborate non-standard linker script used to generate the executable, which is "appended" to the default linker script by specifying the linker script like an input object. All I really would like to do is to specify the start of a new section at a fixed vaddr, but given the kernel elf loader (binfmt_elf) and ld's requirement to have any new section within a page of the last one, I needed to allocate a new phdr to do this. I guess I can always do what you suggest: "gcc -Wl,--verbose 2>&1 | massage_the_script > ld_script", but it is adding another layer of complexity to an already complex method of generating the linker script I have... And BTW, just so you know, I've been using the elf.patch way of doing this by allocating a new phdr *after* all sections have been sized, for a 386 MB executable which is our workhorse process for our primary telecommunications application at Avaya, and "it just works". We haven't hit any issues with "breaking the rules" of assigning a new program header this way in the last 2 years of heavy use... Thanks - Bhavesh |