/* ELF executable support for BFD.
- Copyright 1993, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
static boolean elf_map_symbols PARAMS ((bfd *));
static bfd_size_type get_program_header_size PARAMS ((bfd *));
static boolean elfcore_read_notes PARAMS ((bfd *, bfd_vma, bfd_vma));
+static boolean elf_find_function PARAMS ((bfd *, asection *,
+ asymbol **,
+ bfd_vma, const char **,
+ const char **));
/* Swap version information in and out. The version information is
currently size independent. If that ever changes, this code will
flags |= SEC_CODE;
else if ((flags & SEC_LOAD) != 0)
flags |= SEC_DATA;
+ if ((hdr->sh_flags & SHF_MERGE) != 0)
+ {
+ flags |= SEC_MERGE;
+ newsect->entsize = hdr->sh_entsize;
+ if ((hdr->sh_flags & SHF_STRINGS) != 0)
+ flags |= SEC_STRINGS;
+ }
/* The debugging sections appear to be recognized only by name, not
any sort of flag. */
return bfd_reloc_continue;
}
\f
+/* Finish SHF_MERGE section merging. */
+
+boolean
+_bfd_elf_merge_sections (abfd, info)
+ bfd *abfd;
+ struct bfd_link_info *info;
+{
+ if (elf_hash_table (info)->merge_info)
+ _bfd_merge_sections (abfd, elf_hash_table (info)->merge_info);
+ return true;
+}
+\f
/* Print out the program headers. */
boolean
struct elf_link_hash_entry *h;
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
- h->dynindx = -1;
h->plt.offset = (bfd_vma) -1;
+ if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
+ h->dynindx = -1;
}
/* Initialize an ELF linker hash table. */
table->runpath = NULL;
table->hgot = NULL;
table->stab_info = NULL;
+ table->merge_info = NULL;
table->dynlocal = NULL;
return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
}
this_hdr->sh_flags |= SHF_WRITE;
if ((asect->flags & SEC_CODE) != 0)
this_hdr->sh_flags |= SHF_EXECINSTR;
+ if ((asect->flags & SEC_MERGE) != 0)
+ {
+ this_hdr->sh_flags |= SHF_MERGE;
+ this_hdr->sh_entsize = asect->entsize;
+ if ((asect->flags & SEC_STRINGS) != 0)
+ this_hdr->sh_flags |= SHF_STRINGS;
+ }
/* Check for processor-specific section types. */
if (bed->elf_backend_fake_sections)
case bfd_arch_cris:
i_ehdrp->e_machine = EM_CRIS;
break;
- /* also note that EM_M32, AT&T WE32100 is unknown to bfd */
+ case bfd_arch_openrisc:
+ i_ehdrp->e_machine = EM_OPENRISC;
+ break;
+ /* Also note that EM_M32, AT&T WE32100 is unknown to bfd. */
default:
i_ehdrp->e_machine = EM_NONE;
}
{
_bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem);
- if ((iverdefmem.vd_ndx & VERSYM_VERSION) > maxidx)
- maxidx = iverdefmem.vd_ndx & VERSYM_VERSION;
+ if ((iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION)) > maxidx)
+ maxidx = iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION);
everdef = ((Elf_External_Verdef *)
((bfd_byte *) everdef + iverdefmem.vd_next));
return bfd_default_set_arch_mach (abfd, arch, machine);
}
-/* Find the nearest line to a particular section and offset, for error
- reporting. */
+/* Find the function to a particular section and offset,
+ for error reporting. */
-boolean
-_bfd_elf_find_nearest_line (abfd,
- section,
- symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- line_ptr)
- bfd *abfd;
+static boolean
+elf_find_function (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr)
+ bfd *abfd ATTRIBUTE_UNUSED;
asection *section;
asymbol **symbols;
bfd_vma offset;
CONST char **filename_ptr;
CONST char **functionname_ptr;
- unsigned int *line_ptr;
{
- boolean found;
const char *filename;
asymbol *func;
bfd_vma low_func;
asymbol **p;
- if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
- filename_ptr, functionname_ptr,
- line_ptr))
- return true;
-
- if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
- filename_ptr, functionname_ptr,
- line_ptr, 0,
- &elf_tdata (abfd)->dwarf2_find_line_info))
- return true;
-
- if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
- &found, filename_ptr,
- functionname_ptr, line_ptr,
- &elf_tdata (abfd)->line_info))
- return false;
- if (found)
- return true;
-
- if (symbols == NULL)
- return false;
-
filename = NULL;
func = NULL;
low_func = 0;
if (func == NULL)
return false;
- *filename_ptr = filename;
- *functionname_ptr = bfd_asymbol_name (func);
+ if (filename_ptr)
+ *filename_ptr = filename;
+ if (functionname_ptr)
+ *functionname_ptr = bfd_asymbol_name (func);
+
+ return true;
+}
+
+/* Find the nearest line to a particular section and offset,
+ for error reporting. */
+
+boolean
+_bfd_elf_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
+{
+ boolean found;
+
+ if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr))
+ {
+ if (!*functionname_ptr)
+ elf_find_function (abfd, section, symbols, offset,
+ *filename_ptr ? NULL : filename_ptr,
+ functionname_ptr);
+
+ return true;
+ }
+
+ if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr,
+ line_ptr, 0,
+ &elf_tdata (abfd)->dwarf2_find_line_info))
+ {
+ if (!*functionname_ptr)
+ elf_find_function (abfd, section, symbols, offset,
+ *filename_ptr ? NULL : filename_ptr,
+ functionname_ptr);
+
+ return true;
+ }
+
+ if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+ &found, filename_ptr,
+ functionname_ptr, line_ptr,
+ &elf_tdata (abfd)->line_info))
+ return false;
+ if (found)
+ return true;
+
+ if (symbols == NULL)
+ return false;
+
+ if (! elf_find_function (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr))
+ return false;
+
*line_ptr = 0;
return true;
}