X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-or1k.c;h=4cf0b7cc36ce307b50293a70d29366cb1fdc1fea;hb=747cfc8c6bb23d40b3fa987f6c3df9d3a0d7b817;hp=a2b0ff147fb480283c2fc4330356b5cf4bb8dc39;hpb=c8e98e3692cec125b92c995d8f881d9bdf1fac00;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index a2b0ff147f..4cf0b7cc36 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -1,5 +1,5 @@ /* Or1k-specific support for 32-bit ELF. - Copyright (C) 2001-2018 Free Software Foundation, Inc. + Copyright (C) 2001-2019 Free Software Foundation, Inc. Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org PIC parts added by Stefan Kristiansson, stefan.kristiansson@saunalahti.fi, @@ -1303,7 +1303,7 @@ or1k_elf_relocate_section (bfd *output_bfd, name = bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name); - name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name; + name = name == NULL ? bfd_section_name (sec) : name; } else { @@ -1927,9 +1927,7 @@ or1k_elf_check_relocs (bfd *abfd, /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ case R_OR1K_GNU_VTENTRY: - BFD_ASSERT (h != NULL); - if (h != NULL - && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; break; @@ -2066,8 +2064,7 @@ or1k_elf_check_relocs (bfd *abfd, return FALSE; if (strncmp (name, ".rela", 5) != 0 - || strcmp (bfd_get_section_name (abfd, sec), - name + 5) != 0) + || strcmp (bfd_section_name (sec), name + 5) != 0) { _bfd_error_handler /* xgettext:c-format */ @@ -2379,8 +2376,11 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd, or1k_write_plt_entry (output_bfd, splt->contents + h->plt.offset, plt0, plt1, plt2, OR1K_JR(12)); - /* Fill in the entry in the global offset table. */ - bfd_put_32 (output_bfd, plt_addr, sgot->contents + got_offset); + /* Fill in the entry in the global offset table. We initialize it to + point to the top of the plt. This is done to lazy lookup the actual + symbol as the first plt entry will be setup by libc to call the + runtime dynamic linker. */ + bfd_put_32 (output_bfd, plt_base_addr, sgot->contents + got_offset); /* Fill in the entry in the .rela.plt section. */ rela.r_offset = got_addr; @@ -2995,7 +2995,7 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) + else if (CONST_STRNEQ (bfd_section_name (s), ".rela")) { if (s->size != 0 && s != htab->root.srelplt) relocs = TRUE; @@ -3158,9 +3158,8 @@ or1k_elf_object_p (bfd *abfd) /* Store the machine number in the flags field. */ -static void -or1k_elf_final_write_processing (bfd *abfd, - bfd_boolean linker ATTRIBUTE_UNUSED) +static bfd_boolean +or1k_elf_final_write_processing (bfd *abfd) { switch (bfd_get_mach (abfd)) { @@ -3171,6 +3170,7 @@ or1k_elf_final_write_processing (bfd *abfd, elf_elfheader (abfd)->e_flags |= EF_OR1K_NODELAY; break; } + return _bfd_elf_final_write_processing (abfd); } static bfd_boolean @@ -3226,6 +3226,58 @@ elf32_or1k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) } +/* Implement elf_backend_grok_prstatus: + Support for core dump NOTE sections. */ +static bfd_boolean +or1k_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) +{ + int offset; + size_t size; + + switch (note->descsz) + { + default: + return FALSE; + + case 212: /* Linux/OpenRISC */ + /* pr_cursig */ + elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); + + /* pr_pid */ + elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24); + + /* pr_reg */ + offset = 72; + size = 132; + + break; + } + + /* Make a ".reg/999" section. */ + return _bfd_elfcore_make_pseudosection (abfd, ".reg", + size, note->descpos + offset); +} + +/* Implement elf_backend_grok_psinfo. */ +static bfd_boolean +or1k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) +{ + switch (note->descsz) + { + default: + return FALSE; + + case 128: /* Linux/OpenRISC elf_prpsinfo */ + elf_tdata (abfd)->core->program + = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); + elf_tdata (abfd)->core->command + = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80); + } + + return TRUE; +} + + #define ELF_ARCH bfd_arch_or1k #define ELF_MACHINE_CODE EM_OR1K #define ELF_TARGET_ID OR1K_ELF_DATA @@ -3269,4 +3321,7 @@ elf32_or1k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) #define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol #define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol +#define elf_backend_grok_prstatus or1k_grok_prstatus +#define elf_backend_grok_psinfo or1k_grok_psinfo + #include "elf32-target.h"