Use consistent test for .tbss sections in ldlang.c

Some places tested SEC_LOAD, others SEC_HAS_CONTENTS.

	* ldlang.c (IS_TBSS): New macro, extracted from..
	(IGNORE_SECTION): ..here.
	(lang_size_sections_1): Use IS_TBSS and IGNORE_SECTION.
	(lang_size_sections, lang_do_assignments_1): Use IS_TBSS.
This commit is contained in:
Alan Modra 2016-03-30 17:39:36 +10:30
parent 4ae6cc1962
commit 2e4a7aea70
2 changed files with 15 additions and 12 deletions

View file

@ -1,3 +1,10 @@
2016-03-30 Alan Modra <amodra@gmail.com>
* ldlang.c (IS_TBSS): New macro, extracted from..
(IGNORE_SECTION): ..here.
(lang_size_sections_1): Use IS_TBSS and IGNORE_SECTION.
(lang_size_sections, lang_do_assignments_1): Use IS_TBSS.
2016-03-22 Nick Clifton <nickc@redhat.com> 2016-03-22 Nick Clifton <nickc@redhat.com>
PR ld/19803 PR ld/19803

View file

@ -4697,10 +4697,11 @@ sort_sections_by_lma (const void *arg1, const void *arg2)
return 0; return 0;
} }
#define IS_TBSS(s) \
((s->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == SEC_THREAD_LOCAL)
#define IGNORE_SECTION(s) \ #define IGNORE_SECTION(s) \
((s->flags & SEC_ALLOC) == 0 \ ((s->flags & SEC_ALLOC) == 0 || IS_TBSS (s))
|| ((s->flags & SEC_THREAD_LOCAL) != 0 \
&& (s->flags & SEC_LOAD) == 0))
/* Check to see if any allocated sections overlap with other allocated /* Check to see if any allocated sections overlap with other allocated
sections. This can happen if a linker script specifies the output sections. This can happen if a linker script specifies the output
@ -5109,9 +5110,7 @@ lang_size_sections_1
To avoid warnings about dot moving backwards when using To avoid warnings about dot moving backwards when using
-Ttext, don't start tracking sections until we find one -Ttext, don't start tracking sections until we find one
of non-zero size or with lma set differently to vma. */ of non-zero size or with lma set differently to vma. */
if (((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0 if (!IGNORE_SECTION (os->bfd_section)
|| (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0)
&& (os->bfd_section->flags & SEC_ALLOC) != 0
&& (os->bfd_section->size != 0 && (os->bfd_section->size != 0
|| (r->last_os == NULL || (r->last_os == NULL
&& os->bfd_section->vma != os->bfd_section->lma) && os->bfd_section->vma != os->bfd_section->lma)
@ -5123,8 +5122,7 @@ lang_size_sections_1
r->last_os = s; r->last_os = s;
/* .tbss sections effectively have zero size. */ /* .tbss sections effectively have zero size. */
if ((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0 if (!IS_TBSS (os->bfd_section)
|| (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0
|| bfd_link_relocatable (&link_info)) || bfd_link_relocatable (&link_info))
dotdelta = TO_ADDR (os->bfd_section->size); dotdelta = TO_ADDR (os->bfd_section->size);
else else
@ -5466,8 +5464,7 @@ lang_size_sections (bfd_boolean *relax, bfd_boolean check_regions)
bfd_vma start, end, bump; bfd_vma start, end, bump;
end = start = sec->vma; end = start = sec->vma;
if ((sec->flags & SEC_HAS_CONTENTS) != 0 if (!IS_TBSS (sec))
|| (sec->flags & SEC_THREAD_LOCAL) == 0)
end += sec->size; end += sec->size;
bump = desired_end - end; bump = desired_end - end;
/* We'd like to increase START by BUMP, but we must heed /* We'd like to increase START by BUMP, but we must heed
@ -5563,8 +5560,7 @@ lang_do_assignments_1 (lang_statement_union_type *s,
os, os->fill, dot, found_end); os, os->fill, dot, found_end);
/* .tbss sections effectively have zero size. */ /* .tbss sections effectively have zero size. */
if ((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0 if (!IS_TBSS (os->bfd_section)
|| (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0
|| bfd_link_relocatable (&link_info)) || bfd_link_relocatable (&link_info))
dot += TO_ADDR (os->bfd_section->size); dot += TO_ADDR (os->bfd_section->size);