mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 20:28:28 +08:00
NDS32/bfd: Add one more argument to control contents cache.
The hook bfd_elf32_bfd_get_relocated_section_contents frees contents in gdb, and it make contents pointer mismatched.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2015-02-02 Kuan-Lin Chen <kuanlinchentw@gmail.com>
|
||||||
|
|
||||||
|
* elf32-nds32.c (nds32_get_section_contents): Add one more argument.
|
||||||
|
(nds32_elf_relocate_section): Do not relocate R_NDS32_LONGJUMP7.
|
||||||
|
|
||||||
2015-01-29 Alan Modra <amodra@gmail.com>
|
2015-01-29 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elf64-ppc.c (ppc64_elf_relocate_section): Correct GOT_TLSLD
|
* elf64-ppc.c (ppc64_elf_relocate_section): Correct GOT_TLSLD
|
||||||
|
@ -108,10 +108,11 @@ static Elf_Internal_Rela *find_relocs_at_address
|
|||||||
(Elf_Internal_Rela *, Elf_Internal_Rela *,
|
(Elf_Internal_Rela *, Elf_Internal_Rela *,
|
||||||
Elf_Internal_Rela *, enum elf_nds32_reloc_type);
|
Elf_Internal_Rela *, enum elf_nds32_reloc_type);
|
||||||
static bfd_vma calculate_memory_address
|
static bfd_vma calculate_memory_address
|
||||||
(bfd *, Elf_Internal_Rela *, Elf_Internal_Sym *, Elf_Internal_Shdr *);
|
(bfd *, Elf_Internal_Rela *, Elf_Internal_Sym *, Elf_Internal_Shdr *);
|
||||||
static int nds32_get_section_contents (bfd *, asection *, bfd_byte **);
|
static int nds32_get_section_contents (bfd *, asection *,
|
||||||
|
bfd_byte **, bfd_boolean);
|
||||||
static bfd_boolean nds32_elf_ex9_build_hash_table
|
static bfd_boolean nds32_elf_ex9_build_hash_table
|
||||||
(bfd *, asection *, struct bfd_link_info *);
|
(bfd *, asection *, struct bfd_link_info *);
|
||||||
static bfd_boolean nds32_elf_ex9_itb_base (struct bfd_link_info *);
|
static bfd_boolean nds32_elf_ex9_itb_base (struct bfd_link_info *);
|
||||||
static void nds32_elf_ex9_import_table (struct bfd_link_info *);
|
static void nds32_elf_ex9_import_table (struct bfd_link_info *);
|
||||||
static void nds32_elf_ex9_finish (struct bfd_link_info *);
|
static void nds32_elf_ex9_finish (struct bfd_link_info *);
|
||||||
@ -4512,6 +4513,17 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_ITB_BASE_set == 0)
|
||||||
|
{
|
||||||
|
/* Set the _ITB_BASE_. */
|
||||||
|
if (!nds32_elf_ex9_itb_base (info))
|
||||||
|
{
|
||||||
|
(*_bfd_error_handler) (_("%B: error: Cannot set _ITB_BASE_"),
|
||||||
|
output_bfd);
|
||||||
|
bfd_set_error (bfd_error_bad_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (table->target_optimize & NDS32_RELAX_JUMP_IFC_ON)
|
if (table->target_optimize & NDS32_RELAX_JUMP_IFC_ON)
|
||||||
if (!nds32_elf_ifc_reloc ())
|
if (!nds32_elf_ifc_reloc ())
|
||||||
(*_bfd_error_handler) (_("error: IFC relocation error."));
|
(*_bfd_error_handler) (_("error: IFC relocation error."));
|
||||||
@ -4562,10 +4574,11 @@ nds32_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED,
|
|||||||
|| (r_type >= R_NDS32_INSN16 && r_type <= R_NDS32_25_FIXED_RELA)
|
|| (r_type >= R_NDS32_INSN16 && r_type <= R_NDS32_25_FIXED_RELA)
|
||||||
|| r_type == R_NDS32_DATA
|
|| r_type == R_NDS32_DATA
|
||||||
|| r_type == R_NDS32_TRAN
|
|| r_type == R_NDS32_TRAN
|
||||||
|| (r_type >= R_NDS32_LONGCALL4 && r_type <= R_NDS32_LONGJUMP6))
|
|| (r_type >= R_NDS32_LONGCALL4 && r_type <= R_NDS32_LONGJUMP7))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* If we enter the fp-as-gp region. Resolve the address of best fp-base. */
|
/* If we enter the fp-as-gp region. Resolve the address
|
||||||
|
of best fp-base. */
|
||||||
if (ELF32_R_TYPE (rel->r_info) == R_NDS32_RELAX_REGION_BEGIN
|
if (ELF32_R_TYPE (rel->r_info) == R_NDS32_RELAX_REGION_BEGIN
|
||||||
&& (rel->r_addend & R_NDS32_RELAX_REGION_OMIT_FP_FLAG))
|
&& (rel->r_addend & R_NDS32_RELAX_REGION_OMIT_FP_FLAG))
|
||||||
{
|
{
|
||||||
@ -5946,7 +5959,7 @@ nds32_check_vec_size (bfd *ibfd)
|
|||||||
/* Get vec_size in file. */
|
/* Get vec_size in file. */
|
||||||
unsigned int flag_t;
|
unsigned int flag_t;
|
||||||
|
|
||||||
nds32_get_section_contents (ibfd, sec_t, &contents);
|
nds32_get_section_contents (ibfd, sec_t, &contents, TRUE);
|
||||||
flag_t = bfd_get_32 (ibfd, contents);
|
flag_t = bfd_get_32 (ibfd, contents);
|
||||||
|
|
||||||
/* The value could only be 4 or 16. */
|
/* The value could only be 4 or 16. */
|
||||||
@ -8140,7 +8153,7 @@ is_convert_32_to_16 (bfd *abfd, asection *sec,
|
|||||||
|
|
||||||
offset = reloc->r_offset;
|
offset = reloc->r_offset;
|
||||||
|
|
||||||
if (!nds32_get_section_contents (abfd, sec, &contents))
|
if (!nds32_get_section_contents (abfd, sec, &contents, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
insn = bfd_getb32 (contents + offset);
|
insn = bfd_getb32 (contents + offset);
|
||||||
|
|
||||||
@ -8653,7 +8666,7 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec,
|
|||||||
if (!(sect->flags & SEC_RELOC))
|
if (!(sect->flags & SEC_RELOC))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nds32_get_section_contents (abfd, sect, &contents);
|
nds32_get_section_contents (abfd, sect, &contents, TRUE);
|
||||||
|
|
||||||
for (irel = internal_relocs; irel < irelend; irel++)
|
for (irel = internal_relocs; irel < irelend; irel++)
|
||||||
{
|
{
|
||||||
@ -8901,7 +8914,8 @@ done_adjust_diff:
|
|||||||
/* Get the contents of a section. */
|
/* Get the contents of a section. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nds32_get_section_contents (bfd *abfd, asection *sec, bfd_byte **contents_p)
|
nds32_get_section_contents (bfd *abfd, asection *sec,
|
||||||
|
bfd_byte **contents_p, bfd_boolean cache)
|
||||||
{
|
{
|
||||||
/* Get the section contents. */
|
/* Get the section contents. */
|
||||||
if (elf_section_data (sec)->this_hdr.contents != NULL)
|
if (elf_section_data (sec)->this_hdr.contents != NULL)
|
||||||
@ -8910,6 +8924,7 @@ nds32_get_section_contents (bfd *abfd, asection *sec, bfd_byte **contents_p)
|
|||||||
{
|
{
|
||||||
if (!bfd_malloc_and_get_section (abfd, sec, contents_p))
|
if (!bfd_malloc_and_get_section (abfd, sec, contents_p))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (cache)
|
||||||
elf_section_data (sec)->this_hdr.contents = *contents_p;
|
elf_section_data (sec)->this_hdr.contents = *contents_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12057,7 +12072,7 @@ nds32_elf_relax_section (bfd *abfd, asection *sec,
|
|||||||
load_store_relax = table->load_store_relax;
|
load_store_relax = table->load_store_relax;
|
||||||
|
|
||||||
/* Get symbol table and section content. */
|
/* Get symbol table and section content. */
|
||||||
if (!nds32_get_section_contents (abfd, sec, &contents)
|
if (!nds32_get_section_contents (abfd, sec, &contents, TRUE)
|
||||||
|| !nds32_get_local_syms (abfd, sec, &isymbuf))
|
|| !nds32_get_local_syms (abfd, sec, &isymbuf))
|
||||||
goto error_return;
|
goto error_return;
|
||||||
|
|
||||||
@ -12743,7 +12758,7 @@ nds32_relax_fp_as_gp (struct bfd_link_info *link_info,
|
|||||||
|
|
||||||
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
||||||
|
|
||||||
if (!nds32_get_section_contents (abfd, sec, &contents)
|
if (!nds32_get_section_contents (abfd, sec, &contents, TRUE)
|
||||||
|| !nds32_get_local_syms (abfd, sec, &isymbuf))
|
|| !nds32_get_local_syms (abfd, sec, &isymbuf))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -12880,7 +12895,7 @@ nds32_fag_remove_unused_fpbase (bfd *abfd, asection *sec,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
||||||
nds32_get_section_contents (abfd, sec, &contents);
|
nds32_get_section_contents (abfd, sec, &contents, TRUE);
|
||||||
|
|
||||||
for (irel = internal_relocs; irel < irelend; irel++)
|
for (irel = internal_relocs; irel < irelend; irel++)
|
||||||
{
|
{
|
||||||
@ -12982,7 +12997,7 @@ nds32_elf_get_relocated_section_contents (bfd *abfd,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Read in the section. */
|
/* Read in the section. */
|
||||||
if (!nds32_get_section_contents (input_bfd, input_section, &data))
|
if (!nds32_get_section_contents (input_bfd, input_section, &data, FALSE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (reloc_size == 0)
|
if (reloc_size == 0)
|
||||||
@ -13233,7 +13248,7 @@ nds32_elf_ifc_calc (struct bfd_link_info *info,
|
|||||||
&& !(irel->r_addend & R_NDS32_RELAX_ENTRY_IFC_FLAG)))
|
&& !(irel->r_addend & R_NDS32_RELAX_ENTRY_IFC_FLAG)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (!nds32_get_section_contents (abfd, sec, &contents))
|
if (!nds32_get_section_contents (abfd, sec, &contents, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
table = nds32_elf_hash_table (info);
|
table = nds32_elf_hash_table (info);
|
||||||
@ -13475,7 +13490,7 @@ nds32_elf_ifc_replace (struct bfd_link_info *info)
|
|||||||
irelend = internal_relocs + ptr->sec->reloc_count;
|
irelend = internal_relocs + ptr->sec->reloc_count;
|
||||||
|
|
||||||
if (!nds32_get_section_contents (ptr->sec->owner, ptr->sec,
|
if (!nds32_get_section_contents (ptr->sec->owner, ptr->sec,
|
||||||
&contents))
|
&contents, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while (irel_ptr)
|
while (irel_ptr)
|
||||||
@ -13532,8 +13547,9 @@ nds32_elf_ifc_replace (struct bfd_link_info *info)
|
|||||||
(irel_ptr->sec->owner, irel_ptr->sec, NULL, NULL,
|
(irel_ptr->sec->owner, irel_ptr->sec, NULL, NULL,
|
||||||
TRUE /* keep_memory */);
|
TRUE /* keep_memory */);
|
||||||
irelend = internal_relocs + irel_ptr->sec->reloc_count;
|
irelend = internal_relocs + irel_ptr->sec->reloc_count;
|
||||||
if (!nds32_get_section_contents
|
if (!nds32_get_section_contents (irel_ptr->sec->owner,
|
||||||
(irel_ptr->sec->owner, irel_ptr->sec, &contents))
|
irel_ptr->sec, &contents,
|
||||||
|
TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
irel = irel_ptr->irel;
|
irel = irel_ptr->irel;
|
||||||
@ -13619,7 +13635,8 @@ nds32_elf_ifc_reloc (void)
|
|||||||
if (ptr->h == NULL)
|
if (ptr->h == NULL)
|
||||||
{
|
{
|
||||||
/* Local symbol. */
|
/* Local symbol. */
|
||||||
if (!nds32_get_section_contents (ptr->sec->owner, ptr->sec, &contents))
|
if (!nds32_get_section_contents (ptr->sec->owner, ptr->sec,
|
||||||
|
&contents, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while (irel_ptr)
|
while (irel_ptr)
|
||||||
@ -13717,7 +13734,7 @@ nds32_elf_ifc_reloc (void)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!nds32_get_section_contents
|
if (!nds32_get_section_contents
|
||||||
(irel_ptr->sec->owner, irel_ptr->sec, &contents))
|
(irel_ptr->sec->owner, irel_ptr->sec, &contents, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
insn16 = INSN_IFCALL9 | (relocation >> 1);
|
insn16 = INSN_IFCALL9 | (relocation >> 1);
|
||||||
bfd_putb16 (insn16, contents + irel_ptr->irel->r_offset);
|
bfd_putb16 (insn16, contents + irel_ptr->irel->r_offset);
|
||||||
@ -14172,7 +14189,7 @@ nds32_elf_ex9_build_itable (struct bfd_link_info *link_info)
|
|||||||
table_sec = bfd_get_section_by_name (it_abfd, ".ex9.itable");
|
table_sec = bfd_get_section_by_name (it_abfd, ".ex9.itable");
|
||||||
if (table_sec != NULL)
|
if (table_sec != NULL)
|
||||||
{
|
{
|
||||||
if (!nds32_get_section_contents (it_abfd, table_sec, &contents))
|
if (!nds32_get_section_contents (it_abfd, table_sec, &contents, TRUE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ptr = ex9_insn_head; ptr !=NULL ; ptr = ptr->next)
|
for (ptr = ex9_insn_head; ptr !=NULL ; ptr = ptr->next)
|
||||||
@ -14518,7 +14535,7 @@ nds32_elf_ex9_replace_instruction (struct bfd_link_info *info, bfd *abfd, asecti
|
|||||||
|
|
||||||
|
|
||||||
/* Load section instructions, relocations, and symbol table. */
|
/* Load section instructions, relocations, and symbol table. */
|
||||||
if (!nds32_get_section_contents (abfd, sec, &contents)
|
if (!nds32_get_section_contents (abfd, sec, &contents, TRUE)
|
||||||
|| !nds32_get_local_syms (abfd, sec, &isym))
|
|| !nds32_get_local_syms (abfd, sec, &isym))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
internal_relocs =
|
internal_relocs =
|
||||||
@ -15110,7 +15127,7 @@ nds32_elf_ex9_reloc_jmp (struct bfd_link_info *link_info)
|
|||||||
if (table_sec->size == 0)
|
if (table_sec->size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!nds32_get_section_contents (it_abfd, table_sec, &contents))
|
if (!nds32_get_section_contents (it_abfd, table_sec, &contents, TRUE))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15249,7 +15266,7 @@ nds32_elf_ex9_reloc_jmp (struct bfd_link_info *link_info)
|
|||||||
{
|
{
|
||||||
if (!nds32_get_section_contents
|
if (!nds32_get_section_contents
|
||||||
(fix_ptr->sec->owner, fix_ptr->sec,
|
(fix_ptr->sec->owner, fix_ptr->sec,
|
||||||
&source_contents))
|
&source_contents, TRUE))
|
||||||
(*_bfd_error_handler)
|
(*_bfd_error_handler)
|
||||||
(_("Linker: error cannot fixed ex9 relocation \n"));
|
(_("Linker: error cannot fixed ex9 relocation \n"));
|
||||||
if (temp_ptr->order < 32)
|
if (temp_ptr->order < 32)
|
||||||
@ -15331,7 +15348,7 @@ nds32_elf_ex9_build_hash_table (bfd *abfd, asection *sec,
|
|||||||
|
|
||||||
sym_hashes = elf_sym_hashes (abfd);
|
sym_hashes = elf_sym_hashes (abfd);
|
||||||
/* Load section instructions, relocations, and symbol table. */
|
/* Load section instructions, relocations, and symbol table. */
|
||||||
if (!nds32_get_section_contents (abfd, sec, &contents))
|
if (!nds32_get_section_contents (abfd, sec, &contents, TRUE))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
|
internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
|
||||||
|
Reference in New Issue
Block a user