diff options
author | Alan Modra <amodra@gmail.com> | 2022-02-08 10:40:35 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-02-13 14:00:56 +1030 |
commit | 2085ee26500b2d1b7a11ece8c44395e6403493f4 (patch) | |
tree | c1034f73b7ebc6fddcf1affa2fd2de83006f2771 /ld | |
parent | 7d6aa4b321f2722512be7422394629eec526448b (diff) | |
download | gdb-2085ee26500b2d1b7a11ece8c44395e6403493f4.zip gdb-2085ee26500b2d1b7a11ece8c44395e6403493f4.tar.gz gdb-2085ee26500b2d1b7a11ece8c44395e6403493f4.tar.bz2 |
Don't pass around expld.dataseg pointer
The better to see any code that accesses expld.dataseg.
* ldexp.c (fold_segment_end): Remove seg parameter. Adjust calls.
(fold_segment_align, fold_segment_relro_end): Likewise.
* ldlang.c (lang_size_segment): Likewise.
(lang_size_relro_segment_1, lang_find_relro_sections_1): Likewise.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ldexp.c | 18 | ||||
-rw-r--r-- | ld/ldlang.c | 30 |
2 files changed, 28 insertions, 20 deletions
@@ -340,8 +340,10 @@ update_definedness (const char *name, struct bfd_link_hash_entry *h) } static void -fold_segment_end (seg_align_type *seg) +fold_segment_end (void) { + seg_align_type *seg = &expld.dataseg; + if (expld.phase == lang_first_phase_enum || expld.section != bfd_abs_section_ptr) { @@ -410,7 +412,7 @@ fold_unary (etree_type *tree) break; case DATA_SEGMENT_END: - fold_segment_end (&expld.dataseg); + fold_segment_end (); break; default: @@ -447,8 +449,10 @@ arith_result_section (const etree_value_type *lhs) } static void -fold_segment_align (seg_align_type *seg, etree_value_type *lhs) +fold_segment_align (etree_value_type *lhs) { + seg_align_type *seg = &expld.dataseg; + seg->relro = exp_seg_relro_start; if (expld.phase == lang_first_phase_enum || expld.section != bfd_abs_section_ptr) @@ -494,8 +498,10 @@ fold_segment_align (seg_align_type *seg, etree_value_type *lhs) } static void -fold_segment_relro_end (seg_align_type *seg, etree_value_type *lhs) +fold_segment_relro_end (etree_value_type *lhs) { + seg_align_type *seg = &expld.dataseg; + /* Operands swapped! XXX_SEGMENT_RELRO_END(offset,exp) has offset in expld.result and exp in lhs. */ seg->relro = exp_seg_relro_end; @@ -662,11 +668,11 @@ fold_binary (etree_type *tree) break; case DATA_SEGMENT_ALIGN: - fold_segment_align (&expld.dataseg, &lhs); + fold_segment_align (&lhs); break; case DATA_SEGMENT_RELRO_END: - fold_segment_relro_end (&expld.dataseg, &lhs); + fold_segment_relro_end (&lhs); break; default: diff --git a/ld/ldlang.c b/ld/ldlang.c index f481586..474784c 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -5665,9 +5665,10 @@ os_region_check (lang_output_section_statement_type *os, } static void -ldlang_check_relro_region (lang_statement_union_type *s, - seg_align_type *seg) +ldlang_check_relro_region (lang_statement_union_type *s) { + seg_align_type *seg = &expld.dataseg; + if (seg->relro == exp_seg_relro_start) { if (!seg->relro_start_stat) @@ -6166,7 +6167,7 @@ lang_size_sections_1 output_section_statement->bfd_section, &newdot); - ldlang_check_relro_region (s, &expld.dataseg); + ldlang_check_relro_region (s); expld.dataseg.relro = exp_seg_relro_none; @@ -6346,10 +6347,11 @@ one_lang_size_sections_pass (bool *relax, bool check_regions) } static bool -lang_size_segment (seg_align_type *seg) +lang_size_segment (void) { /* If XXX_SEGMENT_ALIGN XXX_SEGMENT_END pair was seen, check whether a page could be saved in the data segment. */ + seg_align_type *seg = &expld.dataseg; bfd_vma first, last; first = -seg->base & (seg->commonpagesize - 1); @@ -6368,8 +6370,9 @@ lang_size_segment (seg_align_type *seg) } static bfd_vma -lang_size_relro_segment_1 (seg_align_type *seg) +lang_size_relro_segment_1 (void) { + seg_align_type *seg = &expld.dataseg; bfd_vma relro_end, desired_end; asection *sec; @@ -6415,7 +6418,7 @@ lang_size_relro_segment (bool *relax, bool check_regions) if (link_info.relro && expld.dataseg.relro_end) { bfd_vma data_initial_base = expld.dataseg.base; - bfd_vma data_relro_end = lang_size_relro_segment_1 (&expld.dataseg); + bfd_vma data_relro_end = lang_size_relro_segment_1 (); lang_reset_memory_regions (); one_lang_size_sections_pass (relax, check_regions); @@ -6424,11 +6427,11 @@ lang_size_relro_segment (bool *relax, bool check_regions) script have increased padding over the original. Revert. */ if (expld.dataseg.relro_end > data_relro_end) { - expld.dataseg.base = data_initial_base;; + expld.dataseg.base = data_initial_base; do_reset = true; } } - else if (lang_size_segment (&expld.dataseg)) + else if (lang_size_segment ()) do_reset = true; return do_reset; @@ -7679,7 +7682,6 @@ find_relro_section_callback (lang_wild_statement_type *ptr ATTRIBUTE_UNUSED, static void lang_find_relro_sections_1 (lang_statement_union_type *s, - seg_align_type *seg, bool *has_relro_section) { if (*has_relro_section) @@ -7687,7 +7689,7 @@ lang_find_relro_sections_1 (lang_statement_union_type *s, for (; s != NULL; s = s->header.next) { - if (s == seg->relro_end_stat) + if (s == expld.dataseg.relro_end_stat) break; switch (s->header.type) @@ -7699,15 +7701,15 @@ lang_find_relro_sections_1 (lang_statement_union_type *s, break; case lang_constructors_statement_enum: lang_find_relro_sections_1 (constructor_list.head, - seg, has_relro_section); + has_relro_section); break; case lang_output_section_statement_enum: lang_find_relro_sections_1 (s->output_section_statement.children.head, - seg, has_relro_section); + has_relro_section); break; case lang_group_statement_enum: lang_find_relro_sections_1 (s->group_statement.children.head, - seg, has_relro_section); + has_relro_section); break; default: break; @@ -7723,7 +7725,7 @@ lang_find_relro_sections (void) /* Check all sections in the link script. */ lang_find_relro_sections_1 (expld.dataseg.relro_start_stat, - &expld.dataseg, &has_relro_section); + &has_relro_section); if (!has_relro_section) link_info.relro = false; |