https://sourceware.org/bugzilla/show_bug.cgi?id=29861
Bug ID: 29861 Summary: ld: Output Section Type can't be Overwritten / Documentation Unclear Product: binutils Version: 2.39 Status: UNCONFIRMED Severity: minor Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: phip1611 at gmail dot com Target Milestone: --- Since GNU binutils 2.39, specifically commit c212f39d (2022-02-16), the linker script language allows setting a dedicated type for an output section (https://sourceware.org/binutils/docs/ld/Output-Section-Type.html). This works with sections that are only defined by content provided in the linker script, as the following example shows: SECTIONS { foobar (TYPE = SHT_PROGBITS) : { BYTE(1) } } readelf shows exactly the expected type for the foobar section. However, GNU ld ignores this type when an output section contains input sections that already have a certain section type. The following is not possible: .bss . (TYPE = SHT_PROGBITS) : { *(COMMON) *(.bss) } The type is always SHT_NOBITS, no matter what the linker script specifies. This is not only the case for special pre-defined sections, such as .bss. It also applies to custom sections. For example, take a look at the following GAS example: .section .foobar, "ax", @nobits zeroed_buffer: .fill 1024, 1, 0 The section will always be of type SHT_NOBITS, even if the linker script specifies .foobar . (TYPE=SHT_PROGBITS) : { *(.foobar) } So I wonder, is this a bug or intended? If it is intended, the documentation should describe more precisely what this feature is capable of and what the limits are. PS: I work in a project where we need to ensure that memsize==filesize for each section. One solution is to link *(COMMON) and *(.bss) into .data which is of type SHT_PROGBITS. However, I thought the new approach might be more obvious when someone looks at the linker script. However, it doesn't work as I expect. -- You are receiving this mail because: You are on the CC list for the bug.