summaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-06-24 13:25:45 +0930
committerAlan Modra <amodra@gmail.com>2022-06-27 12:28:59 +0930
commit648f6099d4dcadf446f3f00790ad4b16dd4042f6 (patch)
treef806f1f5fa08ad7937c657b8f5107c05afbfee97 /ld/ldlang.c
parentb4eb841afe9306fd7a6df95efcde120bfaa71e32 (diff)
downloadbinutils-gdb-648f6099d4dcadf446f3f00790ad4b16dd4042f6.tar.gz
-z relro relaxation and ld script SIZEOF
A number of targets use assignments like: . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 12 ? 12 : 0, .); (from i386) in linker scripts to put the end of the relro segment past the header in .got.plt. Examination of testcases like those edited by this patch instead sees the end of the relro segment being placed at the start of .got.plt. For the i386 pie1 test: [ 9] .got.plt PROGBITS 00002000 001000 00000c 04 WA 0 0 4 GNU_RELRO 0x000f90 0x00001f90 0x00001f90 0x00070 0x00070 R 0x1 A map file shows: .dynamic 0x0000000000001f90 0x70 *(.dynamic) .dynamic 0x0000000000001f90 0x70 tmpdir/pie1.o 0x0000000000001f90 _DYNAMIC .got 0x0000000000002000 0x0 *(.got) .got 0x0000000000002000 0x0 tmpdir/pie1.o *(.igot) 0x0000000000002ff4 . = DATA_SEGMENT_RELRO_END (., (SIZEOF (.got.plt) >= 0xc)?0xc:0x0) .got.plt 0x0000000000002000 0xc *(.got.plt) .got.plt 0x0000000000002000 0xc tmpdir/pie1.o 0x0000000000002000 _GLOBAL_OFFSET_TABLE_ The DATA_SEGMENT_RELRO_END value in the map file is weird too. All of this is triggered by SIZEOF (.got.plt) being evaluated wrongly as zero. Fix it by taking into account the action of lang_reset_memory_regions during relaxation. * ldexp.c (fold_name <SIZEOF>): Use rawsize if size has been reset. * ldlang.c (lang_size_sections_1): Don't reset processed_vma here. * testsuite/ld-i386/pie1.d: Adjust to suit. * testsuite/ld-x86-64/pr20830a.d: Likewise. * testsuite/ld-x86-64/pr20830b.d: Likewise. * testsuite/ld-x86-64/pr21038a.d: Likewise. * testsuite/ld-x86-64/pr21038b.d: Likewise. * testsuite/ld-x86-64/pr21038c.d: Likewise.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 839535bdb73..e640380e901 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -5778,7 +5778,6 @@ lang_size_sections_1
os->addr_tree = exp_intop (0);
if (os->addr_tree != NULL)
{
- os->processed_vma = false;
exp_fold_tree (os->addr_tree, bfd_abs_section_ptr, &dot);
if (expld.result.valid_p)