aboutsummaryrefslogtreecommitdiff
path: root/ld/ld.texi
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-07-15 08:46:35 +0930
committerAlan Modra <amodra@gmail.com>2023-07-17 08:17:44 +0930
commit63e8fb86255ac97c31d368221be18850ad53039d (patch)
tree508341e8d8cdeab39688128e43308332161307f6 /ld/ld.texi
parent5c77898d60cfea469a86fc6026f51b4a6d8e7444 (diff)
downloadgdb-63e8fb86255ac97c31d368221be18850ad53039d.zip
gdb-63e8fb86255ac97c31d368221be18850ad53039d.tar.gz
gdb-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/ld.texi')
-rw-r--r--ld/ld.texi21
1 files changed, 14 insertions, 7 deletions
diff --git a/ld/ld.texi b/ld/ld.texi
index 40d388a..406e87e 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -7114,10 +7114,13 @@ The builtin function @code{NEXT} is closely related to @code{ALIGN}.
@kindex ALIGNOF(@var{section})
@cindex section alignment
Return the alignment in bytes of the named @var{section}, if that section has
-been allocated. If the section has not been allocated when this is
-evaluated, the linker will report an error. In the following example,
-the alignment of the @code{.output} section is stored as the first
-value in that section.
+been allocated, or zero if the section has not been allocated. If the
+section does not exist in the linker script the linker will report an
+error. If @var{section} is @code{NEXT_SECTION} then @code{ALIGNOF} will
+return the alignment of the next allocated section specified in the
+linker script, or zero if there is no such section. In the following
+example, the alignment of the @code{.output} section is stored as the
+first value in that section.
@smallexample
@group
SECTIONS@{ @dots{}
@@ -7266,9 +7269,13 @@ name.
@kindex SIZEOF(@var{section})
@cindex section size
Return the size in bytes of the named @var{section}, if that section has
-been allocated. If the section has not been allocated when this is
-evaluated, the linker will report an error. In the following example,
-@code{symbol_1} and @code{symbol_2} are assigned identical values:
+been allocated, or zero if the section has not been allocated. If the
+section does not exist in the linker script the linker will report an
+error. If @var{section} is @code{NEXT_SECTION} then @code{SIZEOF} will
+return the alignment of the next allocated section specified in the
+linker script, or zero if there is no such section. In the following
+example, @code{symbol_1} and @code{symbol_2} are assigned identical
+values:
@smallexample
@group
SECTIONS@{ @dots{}