/* ELF executable support for BFD.
- Copyright (C) 1993-2019 Free Software Foundation, Inc.
+ Copyright (C) 1993-2020 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
not any sort of flag. Their SEC_ALLOC bits are cleared. */
if (name [0] == '.')
{
- const char *p;
- int n;
- if (name[1] == 'd')
- p = ".debug", n = 6;
- else if (name[1] == 'g' && name[2] == 'n')
- p = ".gnu.linkonce.wi.", n = 17;
- else if (name[1] == 'g' && name[2] == 'd')
- p = ".gdb_index", n = 11; /* yes we really do mean 11. */
- else if (name[1] == 'l')
- p = ".line", n = 5;
- else if (name[1] == 's')
- p = ".stab", n = 5;
- else if (name[1] == 'z')
- p = ".zdebug", n = 7;
- else
- p = NULL, n = 0;
- if (p != NULL && strncmp (name, p, n) == 0)
+ if (strncmp (name, ".debug", 6) == 0
+ || strncmp (name, ".gnu.linkonce.wi.", 17) == 0
+ || strncmp (name, ".zdebug", 7) == 0)
+ flags |= SEC_DEBUGGING | SEC_ELF_OCTETS;
+ else if (strncmp (name, GNU_BUILD_ATTRS_SECTION_NAME, 21) == 0
+ || strncmp (name, ".note.gnu", 9) == 0)
+ flags |= SEC_ELF_OCTETS;
+ else if (strncmp (name, ".line", 5) == 0
+ || strncmp (name, ".stab", 5) == 0
+ || strcmp (name, ".gdb_index") == 0)
flags |= SEC_DEBUGGING;
}
}
|| (p->p_type == PT_NOTE && bfd_get_format (abfd) == bfd_core))
{
if (!m->includes_filehdr && !m->includes_phdrs)
- p->p_offset = off;
+ {
+ p->p_offset = off;
+ if (no_contents)
+ /* Put meaningless p_offset for PT_LOAD segments
+ without file contents somewhere within the first
+ page, in an attempt to not point past EOF. */
+ p->p_offset = off % (p->p_align > maxpagesize
+ ? p->p_align : maxpagesize);
+ }
else
{
file_ptr adjust;
filename_ptr, functionname_ptr,
line_ptr, discriminator_ptr,
dwarf_debug_sections,
- &elf_tdata (abfd)->dwarf2_find_line_info)
- || _bfd_dwarf1_find_nearest_line (abfd, symbols, section, offset,
- filename_ptr, functionname_ptr,
- line_ptr))
+ &elf_tdata (abfd)->dwarf2_find_line_info))
+ return TRUE;
+
+ if (_bfd_dwarf1_find_nearest_line (abfd, symbols, section, offset,
+ filename_ptr, functionname_ptr, line_ptr))
{
if (!*functionname_ptr)
_bfd_elf_find_function (abfd, symbols, section, offset,
/* address_size and sec->size are in octets. Convert
to bytes before subtracting the original offset. */
- offset = (sec->size - address_size) / bfd_octets_per_byte (abfd) - offset;
+ offset = ((sec->size - address_size)
+ / bfd_octets_per_byte (abfd, sec) - offset);
}
return offset;
}