From 1c9c9b9b55520b36c15af94ee0803f0922b3ca09 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 26 Jan 2021 10:48:09 +1030 Subject: [PATCH] PR27226, ld.bfd contains huge .rodata section This makes it possible to build ld without any compiled-in scripts, by setting COMPILE_IN=no in the environment. pe, beos and pdp11 targets didn't support scripts from the file system, with pdp11 nastily editing the ld/ldscripts file so that the built-in script didn't match. PR 27226 * emulparams/alphavms.sh: Don't set COMPILE_IN. * emulparams/elf64_ia64_vms.sh: Likewise. * emulparams/elf64mmix.sh: Likewise. * emulparams/elf_iamcu.sh: Likewise. * emulparams/elf_k1om.sh: Likewise. * emulparams/elf_l1om.sh: Likewise. * emulparams/mmo.sh: Likewise. * emulparams/pdp11.sh: Set DATA_SEG_ADDR. * scripttempl/pdp11.sc: Use it. * emultempl/pdp11.em: Don't edit .xn script for separate_code, instead use .xe script. Support scripts from file system. * emultempl/beos.em: Support scripts from file system. * emultempl/pe.em: Likewise. * emultempl/pep.em: Likewise. * testsuite/ld-bootstrap/bootstrap.exp: Make tmpdir/ldscripts link. --- ld/ChangeLog | 19 ++++++++++++++ ld/emulparams/alphavms.sh | 3 +-- ld/emulparams/elf64_ia64_vms.sh | 1 - ld/emulparams/elf64mmix.sh | 1 - ld/emulparams/elf_iamcu.sh | 1 - ld/emulparams/elf_k1om.sh | 1 - ld/emulparams/elf_l1om.sh | 1 - ld/emulparams/mmo.sh | 1 - ld/emulparams/pdp11.sh | 5 ++++ ld/emultempl/beos.em | 25 ++++++++++++++++++ ld/emultempl/pdp11.em | 30 ++++++++++++++++++++-- ld/emultempl/pe.em | 34 +++++++++++++++++++++++++ ld/emultempl/pep.em | 34 +++++++++++++++++++++++++ ld/scripttempl/pdp11.sc | 2 +- ld/testsuite/ld-bootstrap/bootstrap.exp | 1 + 15 files changed, 148 insertions(+), 11 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index befdf5bceb5..638f42df990 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,22 @@ +2021-01-26 Alan Modra + + PR 27226 + * emulparams/alphavms.sh: Don't set COMPILE_IN. + * emulparams/elf64_ia64_vms.sh: Likewise. + * emulparams/elf64mmix.sh: Likewise. + * emulparams/elf_iamcu.sh: Likewise. + * emulparams/elf_k1om.sh: Likewise. + * emulparams/elf_l1om.sh: Likewise. + * emulparams/mmo.sh: Likewise. + * emulparams/pdp11.sh: Set DATA_SEG_ADDR. + * scripttempl/pdp11.sc: Use it. + * emultempl/pdp11.em: Don't edit .xn script for separate_code, + instead use .xe script. Support scripts from file system. + * emultempl/beos.em: Support scripts from file system. + * emultempl/pe.em: Likewise. + * emultempl/pep.em: Likewise. + * testsuite/ld-bootstrap/bootstrap.exp: Make tmpdir/ldscripts link. + 2021-01-25 Fangrui Song PR ld/27230 diff --git a/ld/emulparams/alphavms.sh b/ld/emulparams/alphavms.sh index ac9b3a2e6b7..ab69c26e3eb 100644 --- a/ld/emulparams/alphavms.sh +++ b/ld/emulparams/alphavms.sh @@ -3,5 +3,4 @@ SCRIPT_NAME=alphavms OUTPUT_FORMAT="vms-alpha" ARCH=alpha -COMPILE_IN=yes -EXTRA_EM_FILE=vms \ No newline at end of file +EXTRA_EM_FILE=vms diff --git a/ld/emulparams/elf64_ia64_vms.sh b/ld/emulparams/elf64_ia64_vms.sh index 068840281f6..53a6a14d2d4 100644 --- a/ld/emulparams/elf64_ia64_vms.sh +++ b/ld/emulparams/elf64_ia64_vms.sh @@ -3,5 +3,4 @@ SCRIPT_NAME=ia64vms OUTPUT_FORMAT="elf64-ia64-vms" ARCH=ia64 -COMPILE_IN=yes EXTRA_EM_FILE=vms diff --git a/ld/emulparams/elf64mmix.sh b/ld/emulparams/elf64mmix.sh index 75e24be2e2a..fb7c4e31b3e 100644 --- a/ld/emulparams/elf64mmix.sh +++ b/ld/emulparams/elf64mmix.sh @@ -16,7 +16,6 @@ DATA_ADDR='DEFINED (__.MMIX.start..data) ? __.MMIX.start..data : 0x2000000000000 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" ARCH=mmix MACHINE= -COMPILE_IN=yes EXTRA_EM_FILE=mmixelf # The existence of a symbol __start (or _start) should overrule Main, so diff --git a/ld/emulparams/elf_iamcu.sh b/ld/emulparams/elf_iamcu.sh index 1cc07cc720a..c1582235eda 100644 --- a/ld/emulparams/elf_iamcu.sh +++ b/ld/emulparams/elf_iamcu.sh @@ -10,7 +10,6 @@ MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" ARCH=iamcu MACHINE= -COMPILE_IN=yes TEMPLATE_NAME=elf EXTRA_EM_FILE="elf-x86" GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/elf_k1om.sh b/ld/emulparams/elf_k1om.sh index 6f15bdc0572..b27f5ea861a 100644 --- a/ld/emulparams/elf_k1om.sh +++ b/ld/emulparams/elf_k1om.sh @@ -11,7 +11,6 @@ MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" ARCH="k1om" MACHINE= -COMPILE_IN=yes TEMPLATE_NAME=elf EXTRA_EM_FILE="elf-x86" GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/elf_l1om.sh b/ld/emulparams/elf_l1om.sh index 7348c95787f..70d76829d7b 100644 --- a/ld/emulparams/elf_l1om.sh +++ b/ld/emulparams/elf_l1om.sh @@ -11,7 +11,6 @@ MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" ARCH="l1om" MACHINE= -COMPILE_IN=yes TEMPLATE_NAME=elf EXTRA_EM_FILE="elf-x86" GENERATE_SHLIB_SCRIPT=yes diff --git a/ld/emulparams/mmo.sh b/ld/emulparams/mmo.sh index ca98013cafc..6bd84d2e396 100644 --- a/ld/emulparams/mmo.sh +++ b/ld/emulparams/mmo.sh @@ -7,5 +7,4 @@ DATA_ADDR='DEFINED (__.MMIX.start..data) ? __.MMIX.start..data : 0x2000000000000 OUTPUT_FORMAT=mmo RELOCATEABLE_OUTPUT_FORMAT=elf64-mmix ARCH=mmix -COMPILE_IN=yes EXTRA_EM_FILE=mmo diff --git a/ld/emulparams/pdp11.sh b/ld/emulparams/pdp11.sh index 3f3326d121a..d79bb835514 100644 --- a/ld/emulparams/pdp11.sh +++ b/ld/emulparams/pdp11.sh @@ -4,3 +4,8 @@ TEXT_START_ADDR=0 TARGET_PAGE_SIZE=8192 EXTRA_EM_FILE=pdp11 ARCH=pdp11 + +case "$LD_FLAG" in + *textonly) DATA_SEG_ADDR=0 ;; + *) DATA_SEG_ADDR=$DATA_ALIGNMENT ;; +esac diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index bb4395f63ae..fc43ce14677 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -712,7 +712,11 @@ gld${EMULATION_NAME}_place_orphan (asection *s, static char * gld_${EMULATION_NAME}_get_script (int *isfile) EOF + +if test x"$COMPILE_IN" = xyes +then # Scripts compiled in. + # sed commands to quote an ld script as a C string. sc="-f stringify.sed" @@ -734,6 +738,27 @@ echo ' ; else return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c echo '; }' >> e${EMULATION_NAME}.c +else +# Scripts read from the filesystem. + +fragment <> e${EMULATION_NAME}.c echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (link_info.separate_code) return' >> e${EMULATION_NAME}.c -sed $sc ldscripts/${EMULATION_NAME}.xn | \ - sed -e "s/ALIGN($TARGET_PAGE_SIZE)/0/" >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.xe >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c @@ -119,6 +122,29 @@ echo ' ; else return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c echo '; }' >> e${EMULATION_NAME}.c +else +# Scripts read from the filesystem. + +fragment <> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c echo '; }' >> e${EMULATION_NAME}.c +else +# Scripts read from the filesystem. + +fragment <> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c echo '; }' >> e${EMULATION_NAME}.c +else +# Scripts read from the filesystem. + +fragment <