base/ld: only assign .dynamic to the PT_DYNAMIC segment

Segment assignment stays valid for all sections following .dynamic,
which implies that .got and co also end up in the PT_DYNAMIC segment.
This is not intended.  Therefore, we move the .dynamic section before
bss and assign bss to the rw PT_LOAD segment only.

fixes #4750
This commit is contained in:
Sebastian Sumpf 2023-02-01 17:56:26 +01:00 committed by Christian Helmuth
parent 76828f25c5
commit 79d389d812
2 changed files with 25 additions and 19 deletions

View File

@ -212,17 +212,6 @@ SECTIONS
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
.dynamic :
{
*(.dynamic)
/*
* Make sure to have a least one entry within the dynamic section, so the
* dynamic sgement point to something valid in case there are no dynamic
* symbols
*/
LONG(0x0);
} : rw : dynamic
/* merge .got.plt and .got into .got, since the ARM toolchain for OKL4
* set's * DT_PLTGOT to .got instead of .got.plt */
@ -247,6 +236,20 @@ SECTIONS
LONG(0x0);
}
.data1 : { *(.data1) }
.dynamic :
{
*(.dynamic)
/*
* Make sure to have a least one entry within the dynamic section, so the
* dynamic segment points to something valid in case there are no dynamic
* symbols in a binary. These semi-static binaries are not supported by
* our dynamic linker that depends on the .dynamic section.
*/
LONG(0x0);
} : rw : dynamic
_edata = .; PROVIDE (edata = .);
__bss_start = .;
.bss :
@ -264,7 +267,7 @@ SECTIONS
* pad the .data section.
*/
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
} : rw
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
_end = .; PROVIDE (end = .);

View File

@ -97,7 +97,7 @@ SECTIONS
{
/*
* Leave space for parent capability parameters at start of data
* section. The protection domain creator is reponsible for storing
* section. The protection-domain creator is reponsible for storing
* sane values here.
*/
_parent_cap = .;
@ -130,6 +130,7 @@ SECTIONS
.ARM.extab : {
*(.ARM.extab*)
}
__exidx_start = .;
.ARM.exidx : {
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
@ -189,7 +190,6 @@ SECTIONS
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
.data1 : { *(.data1) }
.dynamic : { *(.dynamic) } : dynamic : rw
/* See: genode_dyn.ld */
.got : { *(.got.plt) *(.got) }
/* Exception handling */
@ -199,6 +199,9 @@ SECTIONS
KEEP (*(.eh_frame))
LONG(0)
}
.dynamic : { *(.dynamic) } : rw : dynamic
_edata = .; PROVIDE (edata = .);
__bss_start = .;
.bss :
@ -216,7 +219,7 @@ SECTIONS
* pad the .data section.
*/
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
} : rw
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
_end = .; PROVIDE (end = .);