mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-05 05:01:07 +08:00
include/elf/
* internal.h (ELF_TBSS_SPECIAL): New macro, extracted from.. (ELF_SECTION_SIZE): ..here. (ELF_SECTION_IN_SEGMENT_1): Add "strict" arg. (ELF_SECTION_IN_SEGMENT_STRICT): New macro. bfd/ * elf.c (assign_file_positions_for_load_sections): Check that zero size sections are allocated in segments too. (assign_file_positions_for_non_load_sections): Warn if zero size alloc sections are found here. (copy_elf_program_header): Don't drop zero size sections from segment map. (copy_private_bfd_data): Check for changes in zero size sections. binutils/ * readelf.c (process_program_headers): Don't ignore all zero size sections. ld/testsuite/ * ld-powerpc/tlsexe.r: Update. * ld-powerpc/tlsexetoc.r: Update. * ld-powerpc/tlsso.r: Update. * ld-powerpc/tlstocso.r: Update.
This commit is contained in:
bfd
binutils
include/elf
ld/testsuite
@ -1,3 +1,13 @@
|
|||||||
|
2010-07-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* elf.c (assign_file_positions_for_load_sections): Check that
|
||||||
|
zero size sections are allocated in segments too.
|
||||||
|
(assign_file_positions_for_non_load_sections): Warn if zero
|
||||||
|
size alloc sections are found here.
|
||||||
|
(copy_elf_program_header): Don't drop zero size sections from
|
||||||
|
segment map.
|
||||||
|
(copy_private_bfd_data): Check for changes in zero size sections.
|
||||||
|
|
||||||
2010-07-17 Alan Modra <amodra@gmail.com>
|
2010-07-17 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elf.c (_bfd_elf_map_sections_to_segments): Force new segment
|
* elf.c (_bfd_elf_map_sections_to_segments): Force new segment
|
||||||
|
25
bfd/elf.c
25
bfd/elf.c
@ -4589,8 +4589,7 @@ assign_file_positions_for_load_sections (bfd *abfd,
|
|||||||
|
|
||||||
sec = m->sections[i];
|
sec = m->sections[i];
|
||||||
this_hdr = &(elf_section_data(sec)->this_hdr);
|
this_hdr = &(elf_section_data(sec)->this_hdr);
|
||||||
if (this_hdr->sh_size != 0
|
if (!ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma, 0))
|
||||||
&& !ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma))
|
|
||||||
{
|
{
|
||||||
(*_bfd_error_handler)
|
(*_bfd_error_handler)
|
||||||
(_("%B: section `%A' can't be allocated in segment %d"),
|
(_("%B: section `%A' can't be allocated in segment %d"),
|
||||||
@ -4640,13 +4639,12 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
|
|||||||
BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos);
|
BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos);
|
||||||
else if ((hdr->sh_flags & SHF_ALLOC) != 0)
|
else if ((hdr->sh_flags & SHF_ALLOC) != 0)
|
||||||
{
|
{
|
||||||
if (hdr->sh_size != 0)
|
(*_bfd_error_handler)
|
||||||
((*_bfd_error_handler)
|
(_("%B: warning: allocated section `%s' not in segment"),
|
||||||
(_("%B: warning: allocated section `%s' not in segment"),
|
abfd,
|
||||||
abfd,
|
(hdr->bfd_section == NULL
|
||||||
(hdr->bfd_section == NULL
|
? "*unknown*"
|
||||||
? "*unknown*"
|
: hdr->bfd_section->name));
|
||||||
: hdr->bfd_section->name)));
|
|
||||||
/* We don't need to page align empty sections. */
|
/* We don't need to page align empty sections. */
|
||||||
if ((abfd->flags & D_PAGED) != 0 && hdr->sh_size != 0)
|
if ((abfd->flags & D_PAGED) != 0 && hdr->sh_size != 0)
|
||||||
off += vma_page_aligned_bias (hdr->sh_addr, off,
|
off += vma_page_aligned_bias (hdr->sh_addr, off,
|
||||||
@ -5868,8 +5866,7 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
|
|||||||
section = section->next)
|
section = section->next)
|
||||||
{
|
{
|
||||||
this_hdr = &(elf_section_data(section)->this_hdr);
|
this_hdr = &(elf_section_data(section)->this_hdr);
|
||||||
if (this_hdr->sh_size != 0
|
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
|
||||||
&& ELF_SECTION_IN_SEGMENT (this_hdr, segment))
|
|
||||||
{
|
{
|
||||||
if (!first_section)
|
if (!first_section)
|
||||||
first_section = lowest_section = section;
|
first_section = lowest_section = section;
|
||||||
@ -5948,8 +5945,7 @@ copy_elf_program_header (bfd *ibfd, bfd *obfd)
|
|||||||
section = section->next)
|
section = section->next)
|
||||||
{
|
{
|
||||||
this_hdr = &(elf_section_data(section)->this_hdr);
|
this_hdr = &(elf_section_data(section)->this_hdr);
|
||||||
if (this_hdr->sh_size != 0
|
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
|
||||||
&& ELF_SECTION_IN_SEGMENT (this_hdr, segment))
|
|
||||||
{
|
{
|
||||||
map->sections[isec++] = section->output_section;
|
map->sections[isec++] = section->output_section;
|
||||||
if (isec == section_count)
|
if (isec == section_count)
|
||||||
@ -6026,8 +6022,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd)
|
|||||||
|
|
||||||
/* Check if this section is covered by the segment. */
|
/* Check if this section is covered by the segment. */
|
||||||
this_hdr = &(elf_section_data(section)->this_hdr);
|
this_hdr = &(elf_section_data(section)->this_hdr);
|
||||||
if (this_hdr->sh_size != 0
|
if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
|
||||||
&& ELF_SECTION_IN_SEGMENT (this_hdr, segment))
|
|
||||||
{
|
{
|
||||||
/* FIXME: Check if its output section is changed or
|
/* FIXME: Check if its output section is changed or
|
||||||
removed. What else do we need to check? */
|
removed. What else do we need to check? */
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2010-07-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* readelf.c (process_program_headers): Don't ignore all zero size
|
||||||
|
sections.
|
||||||
|
|
||||||
2010-07-19 Andreas Schwab <schwab@redhat.com>
|
2010-07-19 Andreas Schwab <schwab@redhat.com>
|
||||||
|
|
||||||
* readelf.c (process_section_headers): Update key to flags.
|
* readelf.c (process_section_headers): Update key to flags.
|
||||||
|
@ -3889,8 +3889,8 @@ process_program_headers (FILE * file)
|
|||||||
|
|
||||||
for (j = 1; j < elf_header.e_shnum; j++, section++)
|
for (j = 1; j < elf_header.e_shnum; j++, section++)
|
||||||
{
|
{
|
||||||
if (ELF_SECTION_SIZE (section, segment) != 0
|
if (!ELF_TBSS_SPECIAL (section, segment)
|
||||||
&& ELF_SECTION_IN_SEGMENT (section, segment))
|
&& ELF_SECTION_IN_SEGMENT_STRICT (section, segment))
|
||||||
printf ("%s ", SECTION_NAME (section));
|
printf ("%s ", SECTION_NAME (section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2010-07-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* internal.h (ELF_TBSS_SPECIAL): New macro, extracted from..
|
||||||
|
(ELF_SECTION_SIZE): ..here.
|
||||||
|
(ELF_SECTION_IN_SEGMENT_1): Add "strict" arg.
|
||||||
|
(ELF_SECTION_IN_SEGMENT_STRICT): New macro.
|
||||||
|
|
||||||
2010-06-25 Alan Modra <amodra@gmail.com>
|
2010-06-25 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* ppc64.h (R_PPC64_LO_DS_OPT): Define.
|
* ppc64.h (R_PPC64_LO_DS_OPT): Define.
|
||||||
|
@ -291,37 +291,55 @@ struct elf_segment_map
|
|||||||
|
|
||||||
/* .tbss is special. It doesn't contribute memory space to normal
|
/* .tbss is special. It doesn't contribute memory space to normal
|
||||||
segments and it doesn't take file space in normal segments. */
|
segments and it doesn't take file space in normal segments. */
|
||||||
#define ELF_SECTION_SIZE(sec_hdr, segment) \
|
#define ELF_TBSS_SPECIAL(sec_hdr, segment) \
|
||||||
((!(((sec_hdr)->sh_flags & SHF_TLS) != 0 \
|
(((sec_hdr)->sh_flags & SHF_TLS) != 0 \
|
||||||
&& (sec_hdr)->sh_type == SHT_NOBITS) \
|
&& (sec_hdr)->sh_type == SHT_NOBITS \
|
||||||
|| (segment)->p_type == PT_TLS) ? (sec_hdr)->sh_size : 0)
|
&& (segment)->p_type != PT_TLS)
|
||||||
|
|
||||||
/* Decide if the given sec_hdr is in the given segment. PT_TLS segment
|
#define ELF_SECTION_SIZE(sec_hdr, segment) \
|
||||||
contains only SHF_TLS sections. Only PT_LOAD, PT_GNU_RELRO and
|
(ELF_TBSS_SPECIAL(sec_hdr, segment) ? 0 : (sec_hdr)->sh_size)
|
||||||
and PT_TLS segments can contain SHF_TLS sections. */
|
|
||||||
#define ELF_SECTION_IN_SEGMENT_1(sec_hdr, segment, check_vma) \
|
/* Decide if the section SEC_HDR is in SEGMENT. If CHECK_VMA, then
|
||||||
((((((sec_hdr)->sh_flags & SHF_TLS) != 0) \
|
VMAs are checked for alloc sections. If STRICT, then a zero size
|
||||||
|
section won't match at the end of a segment, unless the segment
|
||||||
|
is also zero size. */
|
||||||
|
#define ELF_SECTION_IN_SEGMENT_1(sec_hdr, segment, check_vma, strict) \
|
||||||
|
((/* Only PT_LOAD, PT_GNU_RELRO and PT_TLS segments can contain \
|
||||||
|
SHF_TLS sections. */ \
|
||||||
|
((((sec_hdr)->sh_flags & SHF_TLS) != 0) \
|
||||||
&& ((segment)->p_type == PT_TLS \
|
&& ((segment)->p_type == PT_TLS \
|
||||||
|| (segment)->p_type == PT_GNU_RELRO \
|
|| (segment)->p_type == PT_GNU_RELRO \
|
||||||
|| (segment)->p_type == PT_LOAD)) \
|
|| (segment)->p_type == PT_LOAD)) \
|
||||||
|
/* PT_TLS segment contains only SHF_TLS sections, PT_PHDR no \
|
||||||
|
sections at all. */ \
|
||||||
|| (((sec_hdr)->sh_flags & SHF_TLS) == 0 \
|
|| (((sec_hdr)->sh_flags & SHF_TLS) == 0 \
|
||||||
&& (segment)->p_type != PT_TLS \
|
&& (segment)->p_type != PT_TLS \
|
||||||
&& (segment)->p_type != PT_PHDR)) \
|
&& (segment)->p_type != PT_PHDR)) \
|
||||||
/* Any section besides one of type SHT_NOBITS must have a file \
|
/* Any section besides one of type SHT_NOBITS must have file \
|
||||||
offset within the segment. */ \
|
offsets within the segment. */ \
|
||||||
&& ((sec_hdr)->sh_type == SHT_NOBITS \
|
&& ((sec_hdr)->sh_type == SHT_NOBITS \
|
||||||
|| ((bfd_vma) (sec_hdr)->sh_offset >= (segment)->p_offset \
|
|| ((bfd_vma) (sec_hdr)->sh_offset >= (segment)->p_offset \
|
||||||
&& ((sec_hdr)->sh_offset + ELF_SECTION_SIZE(sec_hdr, segment) \
|
&& (!(strict) \
|
||||||
<= (segment)->p_offset + (segment)->p_filesz))) \
|
|| ((sec_hdr)->sh_offset - (segment)->p_offset \
|
||||||
/* SHF_ALLOC sections must have VMAs within the segment. Be \
|
<= (segment)->p_filesz - 1)) \
|
||||||
careful about segments right at the end of memory. */ \
|
&& (((sec_hdr)->sh_offset - (segment)->p_offset \
|
||||||
|
+ ELF_SECTION_SIZE(sec_hdr, segment)) \
|
||||||
|
<= (segment)->p_filesz))) \
|
||||||
|
/* SHF_ALLOC sections must have VMAs within the segment. */ \
|
||||||
&& (!(check_vma) \
|
&& (!(check_vma) \
|
||||||
|| ((sec_hdr)->sh_flags & SHF_ALLOC) == 0 \
|
|| ((sec_hdr)->sh_flags & SHF_ALLOC) == 0 \
|
||||||
|| ((sec_hdr)->sh_addr >= (segment)->p_vaddr \
|
|| ((sec_hdr)->sh_addr >= (segment)->p_vaddr \
|
||||||
&& ((sec_hdr)->sh_addr - (segment)->p_vaddr \
|
&& (!(strict) \
|
||||||
+ ELF_SECTION_SIZE(sec_hdr, segment) <= (segment)->p_memsz))))
|
|| ((sec_hdr)->sh_addr - (segment)->p_vaddr \
|
||||||
|
<= (segment)->p_memsz - 1)) \
|
||||||
|
&& (((sec_hdr)->sh_addr - (segment)->p_vaddr \
|
||||||
|
+ ELF_SECTION_SIZE(sec_hdr, segment)) \
|
||||||
|
<= (segment)->p_memsz))))
|
||||||
|
|
||||||
#define ELF_SECTION_IN_SEGMENT(sec_hdr, segment) \
|
#define ELF_SECTION_IN_SEGMENT(sec_hdr, segment) \
|
||||||
(ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1))
|
(ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1, 0))
|
||||||
|
|
||||||
|
#define ELF_SECTION_IN_SEGMENT_STRICT(sec_hdr, segment) \
|
||||||
|
(ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1, 1))
|
||||||
|
|
||||||
#endif /* _ELF_INTERNAL_H */
|
#endif /* _ELF_INTERNAL_H */
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2010-07-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* ld-powerpc/tlsexe.r: Update.
|
||||||
|
* ld-powerpc/tlsexetoc.r: Update.
|
||||||
|
* ld-powerpc/tlsso.r: Update.
|
||||||
|
* ld-powerpc/tlstocso.r: Update.
|
||||||
|
|
||||||
2010-07-20 Alan Modra <amodra@gmail.com>
|
2010-07-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* ld-powerpc/vxworks-relax.s: Add branches to match expected output.
|
* ld-powerpc/vxworks-relax.s: Add branches to match expected output.
|
||||||
|
@ -47,7 +47,7 @@ Program Headers:
|
|||||||
+0+ +
|
+0+ +
|
||||||
+01 +\.interp
|
+01 +\.interp
|
||||||
+02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
+02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
||||||
+03 +\.tdata \.dynamic \.got \.plt
|
+03 +\.tdata \.dynamic (\.branch_lt |)\.got \.plt
|
||||||
+04 +\.dynamic
|
+04 +\.dynamic
|
||||||
+05 +\.tdata \.tbss
|
+05 +\.tdata \.tbss
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Program Headers:
|
|||||||
+0+ +
|
+0+ +
|
||||||
+01 +\.interp
|
+01 +\.interp
|
||||||
+02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
+02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
||||||
+03 +\.tdata \.dynamic \.got \.plt
|
+03 +\.tdata \.dynamic (\.branch_lt |)\.got \.plt
|
||||||
+04 +\.dynamic
|
+04 +\.dynamic
|
||||||
+05 +\.tdata \.tbss
|
+05 +\.tdata \.tbss
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ Program Headers:
|
|||||||
Section to Segment mapping:
|
Section to Segment mapping:
|
||||||
+Segment Sections\.\.\.
|
+Segment Sections\.\.\.
|
||||||
+0+ +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
+0+ +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
||||||
+01 +\.tdata \.dynamic \.got \.plt
|
+01 +\.tdata \.dynamic (\.branch_lt |)\.got \.plt
|
||||||
+02 +\.dynamic
|
+02 +\.dynamic
|
||||||
+03 +\.tdata \.tbss
|
+03 +\.tdata \.tbss
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ Program Headers:
|
|||||||
Section to Segment mapping:
|
Section to Segment mapping:
|
||||||
+Segment Sections\.\.\.
|
+Segment Sections\.\.\.
|
||||||
+0+ +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
+0+ +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
|
||||||
+01 +\.tdata \.dynamic \.got \.plt
|
+01 +\.tdata \.dynamic (\.branch_lt |)\.got \.plt
|
||||||
+02 +\.dynamic
|
+02 +\.dynamic
|
||||||
+03 +\.tdata \.tbss
|
+03 +\.tdata \.tbss
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user