diff options
author | Alan Modra <amodra@gmail.com> | 2023-07-15 08:46:35 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-07-17 08:17:44 +0930 |
commit | 63e8fb86255ac97c31d368221be18850ad53039d (patch) | |
tree | 508341e8d8cdeab39688128e43308332161307f6 /ld/testsuite | |
parent | 5c77898d60cfea469a86fc6026f51b4a6d8e7444 (diff) | |
download | binutils-63e8fb86255ac97c31d368221be18850ad53039d.zip binutils-63e8fb86255ac97c31d368221be18850ad53039d.tar.gz binutils-63e8fb86255ac97c31d368221be18850ad53039d.tar.bz2 |
Support NEXT_SECTION in ALIGNOF and SIZEOF
This patch is aimed at making __bss_start properly aligned with the
first of any bss-style sections following. Most of the work here
involves keeping track of the last output section seen when processing
the linker script.
You can almost align __bss_start properly by using
${RELOCATING+. = ALIGN(${DATA_SDATA-${NO_SMALL_DATA-ALIGNOF(.${SBSS_NAME}) != 0 ? ALIGNOF(.${SBSS_NAME}) : }}${BSS_PLT+ALIGNOF(.plt) != 0 ? ALIGNOF(.plt) : }ALIGNOF(.${BSS_NAME}));}
and changing every place that defines NO_SMALL_DATA to use " ", but
having two .plt sections (marked SPECIAL) on some backends foils that
idea. The problem is that you only want to pick up the following
.plt, not the one preceeding __bss_start in the data segment if the
backend decides that is the proper .plt section.
Perhaps that could be fixed too, but I decided instead to extend the
linker script a little. THIS_SECTION and PREV_SECTION could easily be
added too.
* ld.texi (ALIGNOF, SIZEOF): Update and mention NEXT_SECTION.
* ldexp.c (output_section_find): New function.
(fold_name <ALIGNOF, SIZEOF>): Use output_section_find.
(exp_fold_tree): Add os parameter. Adjust all calls.
(exp_fold_tree_no_dot, exp_get_vma, exp_get_power): Likewise.
* ldexp.h (struct ldexp_control): Add last_os.
(exp_fold_tree, exp_fold_tree_no_dot): Update prototypes.
(exp_get_vma, exp_get_power): Likewise.
* ldlang.c: Pass last output section to expression folder
calls throughout file.
(open_input_bfds): Add os parameter to track last os seen.
(lang_size_sections_1): Rename output_section_statement param
to current_os. Track last os.
(lang_do_assignments_1): Track last os.
* scripttempl/arclinux.sc: Align to ALIGNOF NEXT_SECTION
before defining __bss_start.
* scripttempl/elf.sc: Likewise.
* scripttempl/elf64bpf.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Likewise.
* scripttempl/elfd10v.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/epiphany_4x4.sc: Likewise.
* scripttempl/iq2000.sc: Likewise.
* scripttempl/mep.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/xstormy16.sc: Likewise.
* testsuite/ld-x86-64/pe-x86-64-5.od: Update expected __bss_start.
* testsuite/ld-x86-64/pe-x86-64-5.rd: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-x86-64/pe-x86-64-5.od | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-x86-64/pe-x86-64-5.rd | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/ld/testsuite/ld-x86-64/pe-x86-64-5.od b/ld/testsuite/ld-x86-64/pe-x86-64-5.od index ffd6622..2a1b69b 100644 --- a/ld/testsuite/ld-x86-64/pe-x86-64-5.od +++ b/ld/testsuite/ld-x86-64/pe-x86-64-5.od @@ -6,7 +6,7 @@ SYMBOL TABLE: 0+402010 g .data 0000000000000000 initdummy 0+400000 g .text\$mn 0000000000000000 __executable_start 0+401000 g .text\$mn 0000000000000000 begin -0+402012 g .bss 0000000000000000 __bss_start +0+402014 g .bss 0000000000000000 __bss_start 0+402000 g .data 0000000000000000 Struct 0+402011 g .data 0000000000000000 initializedVar 0+402012 g .data 0000000000000000 _edata diff --git a/ld/testsuite/ld-x86-64/pe-x86-64-5.rd b/ld/testsuite/ld-x86-64/pe-x86-64-5.rd index 2370528..060233e 100644 --- a/ld/testsuite/ld-x86-64/pe-x86-64-5.rd +++ b/ld/testsuite/ld-x86-64/pe-x86-64-5.rd @@ -6,7 +6,7 @@ Symbol table '.symtab' contains 11 entries: +[a-f0-9]+: 0000000000402010 0 NOTYPE GLOBAL DEFAULT 2 initdummy +[a-f0-9]+: 0000000000400000 0 NOTYPE GLOBAL DEFAULT 1 __executable_start +[a-f0-9]+: 0000000000401000 0 NOTYPE GLOBAL DEFAULT 1 begin - +[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 3 __bss_start + +[a-f0-9]+: 0000000000402014 0 NOTYPE GLOBAL DEFAULT 3 __bss_start +[a-f0-9]+: 0000000000402000 0 NOTYPE GLOBAL DEFAULT 2 Struct +[a-f0-9]+: 0000000000402011 0 NOTYPE GLOBAL DEFAULT 2 initializedVar +[a-f0-9]+: 0000000000402012 0 NOTYPE GLOBAL DEFAULT 2 _edata |