public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ld - Add SYMBOL_ABI_ALIGNMENT variable and apply to __bss_start
@ 2023-06-26  9:16 Andreas Krebbel
  2023-06-27 14:14 ` Nick Clifton
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Krebbel @ 2023-06-26  9:16 UTC (permalink / raw)
  To: binutils; +Cc: amodra

Currently not specific alignment is applied to the __bss_start
symbol. However, on s390x we require every symbol to be on an even
address.  The patch introduces a new variable for the elf.sc template
which allows to specify such an symbol alignment requirement.

ld/
	* scripttempl/elf.sc: New variable SYMBOL_ABI_ALIGNMENT. Apply
	to __bss_start.
	* emulparams/elf_s390.sh: Set SYMBOL_ABI_ALIGNMENT to 2.
	* emulparams/elf64_s390.sh: Likewise.
---
 ld/emulparams/elf64_s390.sh | 1 +
 ld/emulparams/elf_s390.sh   | 1 +
 ld/scripttempl/elf.sc       | 5 ++++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ld/emulparams/elf64_s390.sh b/ld/emulparams/elf64_s390.sh
index 899efd7f532..d0a2a59a092 100644
--- a/ld/emulparams/elf64_s390.sh
+++ b/ld/emulparams/elf64_s390.sh
@@ -17,6 +17,7 @@ EXTRA_EM_FILE=s390
 IREL_IN_PLT=
 SEPARATE_GOTPLT=0
 test -z "$RELRO" && unset SEPARATE_GOTPLT
+SYMBOL_ABI_ALIGNMENT=2
 
 # Treat a host that matches the target with the possible exception of "x"
 # in the name as if it were native.
diff --git a/ld/emulparams/elf_s390.sh b/ld/emulparams/elf_s390.sh
index cb1c6b5b04d..1b2fca3f937 100644
--- a/ld/emulparams/elf_s390.sh
+++ b/ld/emulparams/elf_s390.sh
@@ -12,3 +12,4 @@ GENERATE_SHLIB_SCRIPT=yes
 GENERATE_PIE_SCRIPT=yes
 NO_SMALL_DATA=yes
 IREL_IN_PLT=
+SYMBOL_ABI_ALIGNMENT=2
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 1e3c5aa8504..59a851fb47d 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -78,6 +78,8 @@
 #	USER_LABEL_PREFIX - prefix to add to user-visible symbols.
 #	RODATA_NAME, SDATA_NAME, SBSS_NAME, BSS_NAME - base parts of names
 #		for standard sections, without initial "." or suffixes.
+#       SYMBOL_ABI_ALIGNMENT - minimum alignment in bytes which needs to be
+#               applied to every symbol definition
 #
 # When adding sections, do note that the names of some sections are used
 # when specifying the start address of the next.
@@ -165,6 +167,7 @@ if test -z "$GOT"; then
     GOTPLT=".got.plt      ${RELOCATING-0} : { *(.got.plt)${RELOCATING+ *(.igot.plt)} }"
   fi
 fi
+test -z "${SYMBOL_ABI_ALIGNMENT}" && SYMBOL_ABI_ALIGNMENT=1
 REL_IFUNC=".rel.ifunc    ${RELOCATING-0} : { *(.rel.ifunc) }"
 RELA_IFUNC=".rela.ifunc   ${RELOCATING-0} : { *(.rela.ifunc) }"
 REL_IPLT=".rel.iplt     ${RELOCATING-0} :
@@ -678,7 +681,7 @@ cat <<EOF
   ${DATA_SDATA-${OTHER_SDATA_SECTIONS}}
   ${RELOCATING+${DATA_END_SYMBOLS-${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}_edata = .${CREATE_SHLIB+)}; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
   ${PERSISTENT}
-  ${RELOCATING+. = .;}
+  ${RELOCATING+. = ALIGN(${SYMBOL_ABI_ALIGNMENT});}
   ${RELOCATING+${CREATE_SHLIB+PROVIDE (}${USER_LABEL_PREFIX}__bss_start = .${CREATE_SHLIB+)};}
   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
   ${DATA_SDATA-${SBSS}}
-- 
2.40.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-12  1:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26  9:16 [PATCH] ld - Add SYMBOL_ABI_ALIGNMENT variable and apply to __bss_start Andreas Krebbel
2023-06-27 14:14 ` Nick Clifton
2023-06-28  6:23   ` Andreas Krebbel
2023-07-04 12:18   ` [PATCH] Align linkerscript symbols according to ABI Andreas Krebbel
2023-07-05  9:44     ` Nick Clifton
2023-07-05  9:53       ` Andreas Krebbel
2023-07-07  3:03         ` Alan Modra
2023-07-07  9:38           ` Andreas Krebbel
2023-07-12  1:36             ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).