char *e;
bfd_byte *copy;
- if (!sec)
+ if (sec == NULL || (sec->flags & SEC_HAS_CONTENTS) == 0)
return 1;
if (!bfd_malloc_and_get_section (abfd, sec, ©))
different. */
arm_arch_section = bfd_get_section_by_name (abfd, note_section);
- if (arm_arch_section == NULL)
+ if (arm_arch_section == NULL
+ || (arm_arch_section->flags & SEC_HAS_CONTENTS) == 0)
return true;
buffer_size = arm_arch_section->size;
different. */
arm_arch_section = bfd_get_section_by_name (abfd, note_section);
- if (arm_arch_section == NULL)
+ if (arm_arch_section == NULL
+ || (arm_arch_section->flags & SEC_HAS_CONTENTS) == 0)
return bfd_mach_arm_unknown;
buffer_size = arm_arch_section->size;
hdr_info = &htab->eh_info;
if (sec->size == 0
+ || (sec->flags & SEC_HAS_CONTENTS) == 0
|| sec->sec_info_type != SEC_INFO_TYPE_NONE)
{
/* This file does not contain .eh_frame information. */
Consider what happens if someone inept creates a linker script
that puts unwind information in .text. */
s = bfd_get_section_by_name (abfd, ".PARISC.unwind");
- if (s != NULL)
+ if (s != NULL && (s->flags & SEC_HAS_CONTENTS) != 0)
+
{
bfd_size_type size;
bfd_byte *contents;
if (! ((section->flags & SEC_RELOC) != 0
&& section->reloc_count != 0))
continue;
- if ((section->flags & SEC_ALLOC) == 0)
+ if ((section->flags & SEC_ALLOC) == 0
+ || (section->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Get cached copy of section contents if it exists. */
unsigned int symcount;
/* Skip non-code sections and empty sections. */
- if ((section->flags & SEC_CODE) == 0 || section->size == 0)
+ if ((section->flags & SEC_CODE) == 0
+ || (section->flags & SEC_HAS_CONTENTS) == 0
+ || section->size == 0)
continue;
if (section->reloc_count != 0)
int decerr = 0;
if (sec->size == 0
+ || (sec->flags & SEC_HAS_CONTENTS) == 0
|| sec->sec_info_type != SEC_INFO_TYPE_NONE)
{
/* This file does not contain .sframe information. */
}
s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL)
+ if (s != NULL && (s->flags & SEC_HAS_CONTENTS) != 0)
{
unsigned int elfsec;
unsigned long shlink;
if (sec->reloc_count == 0)
continue;
- if ((sec->flags & SEC_EXCLUDE) != 0)
+ if ((sec->flags & SEC_EXCLUDE) != 0
+ || (sec->flags & SEC_HAS_CONTENTS) == 0)
continue;
symtab_hdr = & elf_symtab_hdr (abfd);
/* Find the '.avr.prop' section and load the contents into memory. */
sec = bfd_get_section_by_name (abfd, AVR_PROPERTY_RECORD_SECTION_NAME);
- if (sec == NULL)
+ if (sec == NULL || (sec->flags & SEC_HAS_CONTENTS) == 0)
return NULL;
return avr_elf32_load_records_from_section (abfd, sec);
}
s = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME);
if (s != NULL
&& s->size >= 24
+ && (s->flags & SEC_HAS_CONTENTS) != 0
&& bfd_malloc_and_get_section (abfd, s, &contents))
{
unsigned int apuinfo_size = bfd_get_32 (abfd, contents + 4);
/* If this object was prelinked, the prelinker stored the address
of .glink at got[1]. If it wasn't prelinked, got[1] will be zero. */
dynamic = bfd_get_section_by_name (abfd, ".dynamic");
- if (dynamic != NULL)
+ if (dynamic != NULL
+ && (dynamic->flags & SEC_HAS_CONTENTS) != 0)
{
bfd_byte *dynbuf, *extdyn, *extdynend;
size_t extdynsize;
/* No need to do anything with non-alloc or non-code sections. */
if ((isec->flags & SEC_ALLOC) == 0
|| (isec->flags & SEC_CODE) == 0
+ || (isec->flags & SEC_HAS_CONTENTS) == 0
|| (isec->flags & SEC_LINKER_CREATED) != 0
|| isec->size < 4)
return true;
asection *dynamic, *glink = NULL, *relplt = NULL;
arelent *p;
- if (opd != NULL && !bfd_malloc_and_get_section (abfd, opd, &contents))
+ if (opd != NULL
+ && ((opd->flags & SEC_HAS_CONTENTS) == 0
+ || !bfd_malloc_and_get_section (abfd, opd, &contents)))
{
free_contents_and_exit_err:
count = -1;
size_t extdynsize;
void (*swap_dyn_in) (bfd *, const void *, Elf_Internal_Dyn *);
- if (!bfd_malloc_and_get_section (abfd, dynamic, &dynbuf))
+ if ((dynamic->flags & SEC_HAS_CONTENTS) == 0
+ || !bfd_malloc_and_get_section (abfd, dynamic, &dynbuf))
goto free_contents_and_exit_err;
extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
if (contents == NULL)
{
- if (!bfd_malloc_and_get_section (opd_bfd, opd_sec, &contents))
+ if ((opd_sec->flags & SEC_HAS_CONTENTS) == 0
+ || !bfd_malloc_and_get_section (opd_bfd, opd_sec, &contents))
return (bfd_vma) -1;
ppc64_elf_tdata (opd_bfd)->opd.contents = contents;
}
continue;
sec = bfd_get_section_by_name (ibfd, ".opd");
- if (sec == NULL || sec->size == 0)
+ if (sec == NULL
+ || sec->size == 0
+ || (sec->flags & SEC_HAS_CONTENTS) == 0)
continue;
if (sec->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
toc = bfd_get_section_by_name (ibfd, ".toc");
if (toc == NULL
|| toc->size == 0
+ || (toc->flags & SEC_HAS_CONTENTS) == 0
|| toc->sec_info_type == SEC_INFO_TYPE_JUST_SYMS
|| discarded_section (toc))
continue;
for (j = 0; plts[j].name != NULL; j++)
{
plt = bfd_get_section_by_name (abfd, plts[j].name);
- if (plt == NULL || plt->size == 0)
+ if (plt == NULL
+ || plt->size == 0
+ || (plt->flags & SEC_HAS_CONTENTS) == 0)
continue;
/* Get the PLT section contents. */
| DYN_NO_NEEDED)) == 0;
s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s != NULL && s->size != 0)
+ if (s != NULL && s->size != 0 && (s->flags & SEC_HAS_CONTENTS) != 0)
{
bfd_byte *dynbuf;
bfd_byte *extdyn;
return true;
s = bfd_get_section_by_name (abfd, ".dynamic");
- if (s == NULL || s->size == 0)
+ if (s == NULL || s->size == 0 || (s->flags & SEC_HAS_CONTENTS) == 0)
return true;
if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
bfd_byte *contents, *extdyn, *extdynend;
asection *sec = bfd_get_section_by_name (abfd, ".dynamic");
if (!sec
+ || (sec->flags & SEC_HAS_CONTENTS) == 0
|| sec->size < sizeof (ElfNN_External_Dyn)
|| !bfd_malloc_and_get_section (abfd, sec, &contents))
return ret;
return 0;
plt = bfd_get_section_by_name (abfd, ".plt");
- if (plt == NULL)
+ if (plt == NULL || (plt->flags & SEC_HAS_CONTENTS) == 0)
return 0;
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
sec->owner, sec);
else if (sec->size != 0)
{
- bfd_byte *sec_contents, *l_sec_contents = NULL;
-
- if (!bfd_malloc_and_get_section (sec->owner, sec, &sec_contents))
+ bfd_byte *sec_contents, *l_sec_contents;
+
+ if ((sec->flags & SEC_HAS_CONTENTS) == 0
+ && (l->sec->flags & SEC_HAS_CONTENTS) == 0)
+ ;
+ else if ((sec->flags & SEC_HAS_CONTENTS) == 0
+ || !bfd_malloc_and_get_section (sec->owner, sec,
+ &sec_contents))
info->callbacks->einfo
/* xgettext:c-format */
(_("%pB: could not read contents of section `%pA'\n"),
sec->owner, sec);
- else if (!bfd_malloc_and_get_section (l->sec->owner, l->sec,
- &l_sec_contents))
- info->callbacks->einfo
- /* xgettext:c-format */
- (_("%pB: could not read contents of section `%pA'\n"),
- l->sec->owner, l->sec);
- else if (memcmp (sec_contents, l_sec_contents, sec->size) != 0)
- info->callbacks->einfo
- /* xgettext:c-format */
- (_("%pB: duplicate section `%pA' has different contents\n"),
- sec->owner, sec);
-
- free (sec_contents);
- free (l_sec_contents);
+ else if ((l->sec->flags & SEC_HAS_CONTENTS) == 0
+ || !bfd_malloc_and_get_section (l->sec->owner, l->sec,
+ &l_sec_contents))
+ {
+ info->callbacks->einfo
+ /* xgettext:c-format */
+ (_("%pB: could not read contents of section `%pA'\n"),
+ l->sec->owner, l->sec);
+ free (sec_contents);
+ }
+ else
+ {
+ if (memcmp (sec_contents, l_sec_contents, sec->size) != 0)
+ info->callbacks->einfo
+ /* xgettext:c-format */
+ (_("%pB: duplicate section `%pA' has different contents\n"),
+ sec->owner, sec);
+ free (l_sec_contents);
+ free (sec_contents);
+ }
}
break;
}
sect = bfd_get_section_by_name (abfd, GNU_DEBUGLINK);
- if (sect == NULL)
+ if (sect == NULL || (sect->flags & SEC_HAS_CONTENTS) == 0)
return NULL;
size = bfd_section_size (sect);
sect = bfd_get_section_by_name (abfd, GNU_DEBUGALTLINK);
- if (sect == NULL)
+ if (sect == NULL || (sect->flags & SEC_HAS_CONTENTS) == 0)
return NULL;
size = bfd_section_size (sect);
return (struct bfd_build_id *) abfd->build_id;
sect = bfd_get_section_by_name (abfd, ".note.gnu.build-id");
- if (sect == NULL)
+ if (sect == NULL
+ || (sect->flags & SEC_HAS_CONTENTS) == 0)
{
bfd_set_error (bfd_error_no_debug_section);
return NULL;
{
/* Maybe the extra header isn't there. Look for the section. */
section = bfd_get_section_by_name (abfd, ".idata");
- if (section == NULL)
+ if (section == NULL || (section->flags & SEC_HAS_CONTENTS) == 0)
return true;
addr = section->vma;
int onaline = PDATA_ROW_SIZE;
if (section == NULL
+ || (section->flags & SEC_HAS_CONTENTS) == 0
|| coff_section_data (abfd, section) == NULL
|| pei_section_data (abfd, section) == NULL)
return true;
struct sym_cache cache = {0, 0} ;
if (section == NULL
+ || (section->flags & SEC_HAS_CONTENTS) == 0
|| coff_section_data (abfd, section) == NULL
|| pei_section_data (abfd, section) == NULL)
return true;
asection *section = bfd_get_section_by_name (abfd, ".reloc");
bfd_byte *p, *end;
- if (section == NULL || section->size == 0 || !(section->flags & SEC_HAS_CONTENTS))
+ if (section == NULL
+ || section->size == 0
+ || (section->flags & SEC_HAS_CONTENTS) == 0)
return true;
fprintf (file,
/* Sanity checks. */
if (pdata_section == NULL
+ || (pdata_section->flags & SEC_HAS_CONTENTS) == 0
|| coff_section_data (abfd, pdata_section) == NULL
|| pei_section_data (abfd, pdata_section) == NULL)
return true;
xdata_section = pex64_get_section_by_rva (abfd, xdata_base, ".text");
/* Transfer xdata section into xdata array. */
if (!xdata_section
+ || (xdata_section->flags & SEC_HAS_CONTENTS) == 0
|| !bfd_malloc_and_get_section (abfd, xdata_section, &xdata))
goto done;
bfd_size_type *pstridx;
if (stabsec->size == 0
- || stabstrsec->size == 0)
+ || stabstrsec->size == 0
+ || (stabsec->flags & SEC_HAS_CONTENTS) == 0
+ || (stabstrsec->flags & SEC_HAS_CONTENTS) == 0)
/* This file does not contain stabs debugging information. */
return true;
bfd_size_type *pstridx;
int deleting;
- if (stabsec->size == 0)
+ if (stabsec->size == 0 || (stabsec->flags & SEC_HAS_CONTENTS) == 0)
/* This file does not contain stabs debugging information. */
return false;
}
lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
+ if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
{
bfd_set_error (bfd_error_no_symbols);
return -1;
}
lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
+ if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
{
bfd_set_error (bfd_error_no_symbols);
return -1;
}
lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
+ if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
{
bfd_set_error (bfd_error_no_symbols);
return -1;
}
lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
+ if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
{
bfd_set_error (bfd_error_no_symbols);
return -1;
o_snloader field in the a.out header, rather than grabbing the
section by name. */
lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
+ if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
{
_bfd_error_handler
(_("%pB: dynamic object with no .loader section"),
*pneeded = false;
lsec = bfd_get_section_by_name (abfd, ".loader");
- if (lsec == NULL)
+ if (lsec == NULL || (lsec->flags & SEC_HAS_CONTENTS) == 0)
/* There are no symbols, so don't try to include it. */
return true;
{
/* Grab the contents of SUB's .debug section, if any. */
subdeb = bfd_get_section_by_name (sub, ".debug");
- if (subdeb != NULL && subdeb->size > 0)
+ if (subdeb != NULL
+ && subdeb->size != 0
+ && (subdeb->flags & SEC_HAS_CONTENTS) != 0)
{
/* We use malloc and copy the names into the debug
stringtab, rather than bfd_alloc, because I expect