mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 18:39:34 +08:00
Get rid of SEC_ELF_COMPRESS
This flag also isn't needed, except for some sanity checks which we can omit. * elf.c (elf_fake_sections): Don't set SEC_ELF_COMPRESS for compressed debug sections, just leave sh_name as -1. (assign_file_positions_for_non_load_sections), (assign_file_positions_except_relocs): Decide whether a section needs compressing and thus should not have its file offset set by looking at sh_name. (_bfd_elf_assign_file_positions_for_non_load): Similarly decide which sections need compressing. * elflink.c (bfd_elf_final_link): Don't test SEC_ELF_COMPRESS. * merge.c (_bfd_write_merged_section): Likewise. * section.c (SEC_ELF_COMPRESS): Don't define. (SEC_ELF_PURECODE): Renumber. * bfd-in2.h: Regenerate.
This commit is contained in:
@ -921,9 +921,8 @@ typedef struct bfd_section
|
||||
executables or shared objects. This is for COFF only. */
|
||||
#define SEC_COFF_SHARED 0x8000000
|
||||
|
||||
/* This section should be compressed. This is for ELF linker
|
||||
internal use only. */
|
||||
#define SEC_ELF_COMPRESS 0x8000000
|
||||
/* Indicate that section has the purecode flag set. */
|
||||
#define SEC_ELF_PURECODE 0x8000000
|
||||
|
||||
/* When a section with this flag is being linked, then if the size of
|
||||
the input section is less than a page, it should not cross a page
|
||||
@ -949,9 +948,6 @@ typedef struct bfd_section
|
||||
when memory read flag isn't set. */
|
||||
#define SEC_COFF_NOREAD 0x40000000
|
||||
|
||||
/* Indicate that section has the purecode flag set. */
|
||||
#define SEC_ELF_PURECODE 0x80000000
|
||||
|
||||
/* End of section flags. */
|
||||
|
||||
/* Some internal packed boolean fields. */
|
||||
|
63
bfd/elf.c
63
bfd/elf.c
@ -3174,9 +3174,6 @@ elf_fake_sections (bfd *abfd, asection *asect, void *fsarg)
|
||||
&& name[1] == 'd'
|
||||
&& name[6] == '_')
|
||||
{
|
||||
/* Set SEC_ELF_COMPRESS to indicate this section should be
|
||||
compressed. */
|
||||
asect->flags |= SEC_ELF_COMPRESS;
|
||||
/* If this section will be compressed, delay adding section
|
||||
name to section name section after it is compressed in
|
||||
_bfd_elf_assign_file_positions_for_non_load. */
|
||||
@ -6189,10 +6186,10 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
|
||||
&& hdr->bfd_section == NULL)
|
||||
/* We don't know the offset of these sections yet:
|
||||
their size has not been decided. */
|
||||
|| (hdr->bfd_section != NULL
|
||||
&& (hdr->bfd_section->flags & SEC_ELF_COMPRESS
|
||||
|| (bfd_section_is_ctf (hdr->bfd_section)
|
||||
&& abfd->is_linker_output)))
|
||||
|| (abfd->is_linker_output
|
||||
&& hdr->bfd_section != NULL
|
||||
&& (hdr->sh_name == -1u
|
||||
|| bfd_section_is_ctf (hdr->bfd_section)))
|
||||
|| hdr == i_shdrpp[elf_onesymtab (abfd)]
|
||||
|| (elf_symtab_shndx_list (abfd) != NULL
|
||||
&& hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx])
|
||||
@ -6424,10 +6421,10 @@ assign_file_positions_except_relocs (bfd *abfd,
|
||||
&& hdr->bfd_section == NULL)
|
||||
/* Do not assign offsets for these sections yet: we don't know
|
||||
their sizes. */
|
||||
|| (hdr->bfd_section != NULL
|
||||
&& (hdr->bfd_section->flags & SEC_ELF_COMPRESS
|
||||
|| (bfd_section_is_ctf (hdr->bfd_section)
|
||||
&& abfd->is_linker_output)))
|
||||
|| (abfd->is_linker_output
|
||||
&& hdr->bfd_section != NULL
|
||||
&& (hdr->sh_name == -1u
|
||||
|| bfd_section_is_ctf (hdr->bfd_section)))
|
||||
|| i == elf_onesymtab (abfd)
|
||||
|| (elf_symtab_shndx_list (abfd) != NULL
|
||||
&& hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx])
|
||||
@ -6630,21 +6627,23 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
|
||||
if (shdrp->sh_offset == -1)
|
||||
{
|
||||
asection *sec = shdrp->bfd_section;
|
||||
bool is_rel = (shdrp->sh_type == SHT_REL
|
||||
|| shdrp->sh_type == SHT_RELA);
|
||||
bool is_ctf = sec && bfd_section_is_ctf (sec);
|
||||
if (is_rel
|
||||
|| is_ctf
|
||||
|| (sec != NULL && (sec->flags & SEC_ELF_COMPRESS)))
|
||||
if (sec == NULL
|
||||
|| shdrp->sh_type == SHT_REL
|
||||
|| shdrp->sh_type == SHT_RELA)
|
||||
;
|
||||
else if (bfd_section_is_ctf (sec))
|
||||
{
|
||||
if (!is_rel && !is_ctf)
|
||||
/* Update section size and contents. */
|
||||
shdrp->sh_size = sec->size;
|
||||
shdrp->contents = sec->contents;
|
||||
}
|
||||
else if (shdrp->sh_name == -1u)
|
||||
{
|
||||
const char *name = sec->name;
|
||||
struct bfd_elf_section_data *d;
|
||||
|
||||
/* Compress DWARF debug sections. */
|
||||
if (!bfd_compress_section (abfd, sec,
|
||||
shdrp->contents))
|
||||
if (!bfd_compress_section (abfd, sec, shdrp->contents))
|
||||
return false;
|
||||
|
||||
if (sec->compress_status == COMPRESS_SECTION_DONE
|
||||
@ -6659,8 +6658,6 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
|
||||
name = new_name;
|
||||
}
|
||||
/* Add section name to section name section. */
|
||||
if (shdrp->sh_name != (unsigned int) -1)
|
||||
abort ();
|
||||
shdrp->sh_name
|
||||
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
|
||||
name, false);
|
||||
@ -6679,18 +6676,10 @@ _bfd_elf_assign_file_positions_for_non_load (bfd *abfd)
|
||||
/* Update section size and contents. */
|
||||
shdrp->sh_size = sec->size;
|
||||
shdrp->contents = sec->contents;
|
||||
shdrp->bfd_section->contents = NULL;
|
||||
}
|
||||
else if (is_ctf)
|
||||
{
|
||||
/* Update section size and contents. */
|
||||
shdrp->sh_size = sec->size;
|
||||
shdrp->contents = sec->contents;
|
||||
sec->contents = NULL;
|
||||
}
|
||||
|
||||
off = _bfd_elf_assign_file_position_for_section (shdrp, off,
|
||||
true);
|
||||
}
|
||||
off = _bfd_elf_assign_file_position_for_section (shdrp, off, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9469,16 +9458,6 @@ _bfd_elf_set_section_contents (bfd *abfd,
|
||||
later. */
|
||||
return true;
|
||||
|
||||
if ((section->flags & SEC_ELF_COMPRESS) == 0)
|
||||
{
|
||||
_bfd_error_handler
|
||||
(_("%pB:%pA: error: attempting to write"
|
||||
" into an unallocated compressed section"),
|
||||
abfd, section);
|
||||
bfd_set_error (bfd_error_invalid_operation);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((offset + count) > hdr->sh_size)
|
||||
{
|
||||
_bfd_error_handler
|
||||
|
@ -12559,7 +12559,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
|
||||
later. Use bfd_malloc since it will be freed by
|
||||
bfd_compress_section_contents. */
|
||||
unsigned char *contents = esdo->this_hdr.contents;
|
||||
if ((o->flags & SEC_ELF_COMPRESS) == 0 || contents != NULL)
|
||||
if (contents != NULL)
|
||||
abort ();
|
||||
contents
|
||||
= (unsigned char *) bfd_malloc (esdo->this_hdr.sh_size);
|
||||
|
@ -850,8 +850,7 @@ _bfd_write_merged_section (bfd *output_bfd, asection *sec, void *psecinfo)
|
||||
/* We must compress this section. Write output to the
|
||||
buffer. */
|
||||
contents = hdr->contents;
|
||||
if ((sec->output_section->flags & SEC_ELF_COMPRESS) == 0
|
||||
|| contents == NULL)
|
||||
if (contents == NULL)
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
|
@ -336,9 +336,8 @@ CODE_FRAGMENT
|
||||
. executables or shared objects. This is for COFF only. *}
|
||||
.#define SEC_COFF_SHARED 0x8000000
|
||||
.
|
||||
. {* This section should be compressed. This is for ELF linker
|
||||
. internal use only. *}
|
||||
.#define SEC_ELF_COMPRESS 0x8000000
|
||||
. {* Indicate that section has the purecode flag set. *}
|
||||
.#define SEC_ELF_PURECODE 0x8000000
|
||||
.
|
||||
. {* When a section with this flag is being linked, then if the size of
|
||||
. the input section is less than a page, it should not cross a page
|
||||
@ -364,9 +363,6 @@ CODE_FRAGMENT
|
||||
. when memory read flag isn't set. *}
|
||||
.#define SEC_COFF_NOREAD 0x40000000
|
||||
.
|
||||
. {* Indicate that section has the purecode flag set. *}
|
||||
.#define SEC_ELF_PURECODE 0x80000000
|
||||
.
|
||||
. {* End of section flags. *}
|
||||
.
|
||||
. {* Some internal packed boolean fields. *}
|
||||
|
Reference in New Issue
Block a user