determining output section type

Rasmus Villemoes rasmus.villemoes@prevas.dk
Wed Nov 3 12:40:52 GMT 2021


Hi

I've observed that there has been some change between 2.34 and 2.35 (and
from some 'git grep'/'git blame' I suspect commit 8c803a2dd7d3
(elf_backend_section_flags and _bfd_elf_init_private_section_data))
which ends up breaking module loading on our old vxworks platform.

The issue is that the .data section now ends up having type INIT_ARRAY
rather than PROGBITS, and the ELF loader on target doesn't know anything
about that section type, so it ignores it. We use a custom linker
script, part of which reads

    .data 0 :
    {
	PROVIDE(__start_data = .);

	_ctors = .;
	KEEP (*(.preinit_array))
	KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
	KEEP (*(.init_array))
	LONG(0)

...
	*(.data)
	*(.data.*) *(.gnu.linkonce.d*) *(.data1)
	PROVIDE(__stop_data = .);
    }

If I rearrange this to put the *(.data) stanza at the beginning, the
.data section in the output file does get type PROGBITS, but only if any
of the input .data sections are non-empty. I could arrange for that in
the toolchain I build since that includes linking in a crtbegin.o that I
control, but it seems a little wasteful and fragile.

Is there some way in the linker script (or otherwise) to force .data to
have type PROGBITS? I'd rather not need a post-processing step editing
the ELF file, even if it could be done with objcopy or similar.

Rasmus


More information about the Binutils mailing list