diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-11-11 07:02:30 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-11-12 17:26:11 -0800 |
commit | ed1794ee7a2bd8adc22e5bb8e7343b72758d5692 (patch) | |
tree | 1b32fedc7ee60aaf9b9af9bccd7272d4665b0e89 /ld/ldlang.c | |
parent | f4d18a54667ded2b50894a3d0740f93825f2a3e8 (diff) | |
download | gdb-ed1794ee7a2bd8adc22e5bb8e7343b72758d5692.zip gdb-ed1794ee7a2bd8adc22e5bb8e7343b72758d5692.tar.gz gdb-ed1794ee7a2bd8adc22e5bb8e7343b72758d5692.tar.bz2 |
ld: Add ldlang_check_relro_region/update lang_find_relro_sections_1
Extract GNU_RELRO region check into a new funtion and pass a pointer to
seg_align_type to lang_find_relro_sections_1 so that they can also be
used for text-only LOAD segment.
* ldlang.c (lang_size_sections_1): Extract GNU_RELRO region check
into ...
(ldlang_check_relro_region): New function.
(lang_find_relro_sections_1): Add an argument for pointer to
seg_align_type and replace expld.dataseg with the pointer.
(lang_find_relro_sections): Pass address of expld.dataseg to
lang_find_relro_sections_1.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 6bb9e47..674004e 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4975,6 +4975,30 @@ os_region_check (lang_output_section_statement_type *os, } } +static void +ldlang_check_relro_region (lang_statement_union_type *s, + seg_align_type *seg) +{ + if (seg->relro == exp_seg_relro_start) + { + if (!seg->relro_start_stat) + seg->relro_start_stat = s; + else + { + ASSERT (seg->relro_start_stat == s); + } + } + else if (seg->relro == exp_seg_relro_end) + { + if (!seg->relro_end_stat) + seg->relro_end_stat = s; + else + { + ASSERT (seg->relro_end_stat == s); + } + } +} + /* Set the sizes for all the output sections. */ static bfd_vma @@ -5432,24 +5456,8 @@ lang_size_sections_1 output_section_statement->bfd_section, &newdot); - if (expld.dataseg.relro == exp_seg_relro_start) - { - if (!expld.dataseg.relro_start_stat) - expld.dataseg.relro_start_stat = s; - else - { - ASSERT (expld.dataseg.relro_start_stat == s); - } - } - else if (expld.dataseg.relro == exp_seg_relro_end) - { - if (!expld.dataseg.relro_end_stat) - expld.dataseg.relro_end_stat = s; - else - { - ASSERT (expld.dataseg.relro_end_stat == s); - } - } + ldlang_check_relro_region (s, &expld.dataseg); + expld.dataseg.relro = exp_seg_relro_none; /* This symbol may be relative to this section. */ @@ -6859,6 +6867,7 @@ 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, bfd_boolean *has_relro_section) { if (*has_relro_section) @@ -6866,7 +6875,7 @@ lang_find_relro_sections_1 (lang_statement_union_type *s, for (; s != NULL; s = s->header.next) { - if (s == expld.dataseg.relro_end_stat) + if (s == seg->relro_end_stat) break; switch (s->header.type) @@ -6878,15 +6887,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, - has_relro_section); + seg, has_relro_section); break; case lang_output_section_statement_enum: lang_find_relro_sections_1 (s->output_section_statement.children.head, - has_relro_section); + seg, has_relro_section); break; case lang_group_statement_enum: lang_find_relro_sections_1 (s->group_statement.children.head, - has_relro_section); + seg, has_relro_section); break; default: break; @@ -6902,7 +6911,7 @@ lang_find_relro_sections (void) /* Check all sections in the link script. */ lang_find_relro_sections_1 (expld.dataseg.relro_start_stat, - &has_relro_section); + &expld.dataseg, &has_relro_section); if (!has_relro_section) link_info.relro = FALSE; |