projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a use-after-free bug in the BFD library when scanning a corrupt ELF file.
[deliverable/binutils-gdb.git]
/
bfd
/
elf32-cris.c
diff --git
a/bfd/elf32-cris.c
b/bfd/elf32-cris.c
index 061629947fc8a1b025368f196aef346fcfefad0d..bee7108684924e98b2fc5e83896cd43c06259b60 100644
(file)
--- a/
bfd/elf32-cris.c
+++ b/
bfd/elf32-cris.c
@@
-1,5
+1,5
@@
/* CRIS-specific support for 32-bit ELF.
/* CRIS-specific support for 32-bit ELF.
- Copyright (C) 2000-20
17
Free Software Foundation, Inc.
+ Copyright (C) 2000-20
20
Free Software Foundation, Inc.
Contributed by Axis Communications AB.
Written by Hans-Peter Nilsson, based on elf32-fr30.c
PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c.
Contributed by Axis Communications AB.
Written by Hans-Peter Nilsson, based on elf32-fr30.c
PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c.
@@
-453,7
+453,7
@@
cris_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
/* Set the howto pointer for an CRIS ELF reloc. */
/* Set the howto pointer for an CRIS ELF reloc. */
-static
void
+static
bfd_boolean
cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
arelent * cache_ptr,
Elf_Internal_Rela * dst)
cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
arelent * cache_ptr,
Elf_Internal_Rela * dst)
@@
-464,10
+464,13
@@
cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
if (r_type >= R_CRIS_max)
{
/* xgettext:c-format */
if (r_type >= R_CRIS_max)
{
/* xgettext:c-format */
- _bfd_error_handler (_("%B: invalid CRIS reloc number: %d"), abfd, r_type);
- r_type = 0;
+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+ abfd, r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
}
cache_ptr->howto = & cris_elf_howto_table [r_type];
}
cache_ptr->howto = & cris_elf_howto_table [r_type];
+ return TRUE;
}
bfd_reloc_status_type
}
bfd_reloc_status_type
@@
-886,7
+889,7
@@
static struct bfd_link_hash_table *
elf_cris_link_hash_table_create (bfd *abfd)
{
struct elf_cris_link_hash_table *ret;
elf_cris_link_hash_table_create (bfd *abfd)
{
struct elf_cris_link_hash_table *ret;
-
bfd_size_type
amt = sizeof (struct elf_cris_link_hash_table);
+
size_t
amt = sizeof (struct elf_cris_link_hash_table);
ret = ((struct elf_cris_link_hash_table *) bfd_zmalloc (amt));
if (ret == (struct elf_cris_link_hash_table *) NULL)
ret = ((struct elf_cris_link_hash_table *) bfd_zmalloc (amt));
if (ret == (struct elf_cris_link_hash_table *) NULL)
@@
-1041,7
+1044,7
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
symname = (bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name));
if (symname == NULL)
symname = (bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name));
if (symname == NULL)
- symname = bfd_section_name (
input_bfd,
sec);
+ symname = bfd_section_name (sec);
}
else
{
}
else
{
@@
-1113,7
+1116,7
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
{
_bfd_error_handler
/* xgettext:c-format */
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %
A: unresolvable relocation %s against symbol `%s'"),
+ (_("%
pB, section %p
A: unresolvable relocation %s against symbol `%s'"),
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
@@
-1178,10
+1181,10
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
_bfd_error_handler
((h->got.offset == (bfd_vma) -1)
/* xgettext:c-format */
_bfd_error_handler
((h->got.offset == (bfd_vma) -1)
/* xgettext:c-format */
- ? _("%
B, section %A: N
o PLT nor GOT for relocation %s"
+ ? _("%
pB, section %pA: n
o PLT nor GOT for relocation %s"
" against symbol `%s'")
/* xgettext:c-format */
" against symbol `%s'")
/* xgettext:c-format */
- : _("%
B, section %A: N
o PLT for relocation %s"
+ : _("%
pB, section %pA: n
o PLT for relocation %s"
" against symbol `%s'"),
input_bfd,
input_section,
" against symbol `%s'"),
input_bfd,
input_section,
@@
-1305,21
+1308,21
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
if (h == NULL)
_bfd_error_handler
/* xgettext:c-format */
if (h == NULL)
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %A: relocation %s with non-zero addend %L
d"
- " against local symbol"),
+ (_("%
pB, section %pA: relocation %s with non-zero adden
d"
+ "
%" PRId64 "
against local symbol"),
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
- rel->r_addend);
+
(int64_t)
rel->r_addend);
else
_bfd_error_handler
/* xgettext:c-format */
else
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %A: relocation %s with non-zero addend %L
d"
- " against symbol `%s'"),
+ (_("%
pB, section %pA: relocation %s with non-zero adden
d"
+ "
%" PRId64 "
against symbol `%s'"),
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
- rel->r_addend,
+
(int64_t)
rel->r_addend,
symname[0] != '\0' ? symname : _("[whose name is lost]"));
bfd_set_error (bfd_error_bad_value);
symname[0] != '\0' ? symname : _("[whose name is lost]"));
bfd_set_error (bfd_error_bad_value);
@@
-1341,7
+1344,7
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
{
_bfd_error_handler
/* xgettext:c-format */
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %
A: relocation %s is"
+ (_("%
pB, section %p
A: relocation %s is"
" not allowed for global symbol: `%s'"),
input_bfd,
input_section,
" not allowed for global symbol: `%s'"),
input_bfd,
input_section,
@@
-1358,7
+1361,7
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
{
_bfd_error_handler
/* xgettext:c-format */
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %
A: relocation %s with no GOT created"),
+ (_("%
pB, section %p
A: relocation %s with no GOT created"),
input_bfd,
input_section,
cris_elf_howto_table[r_type].name);
input_bfd,
input_section,
cris_elf_howto_table[r_type].name);
@@
-1575,10
+1578,10
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
((h->root.type == bfd_link_hash_undefined)
/* We shouldn't get here for GCC-emitted code. */
/* xgettext:c-format */
((h->root.type == bfd_link_hash_undefined)
/* We shouldn't get here for GCC-emitted code. */
/* xgettext:c-format */
- ? _("%
B, section %
A: relocation %s has an undefined"
+ ? _("%
pB, section %p
A: relocation %s has an undefined"
" reference to `%s', perhaps a declaration mixup?")
/* xgettext:c-format */
" reference to `%s', perhaps a declaration mixup?")
/* xgettext:c-format */
- : _("%
B, section %
A: relocation %s is"
+ : _("%
pB, section %p
A: relocation %s is"
" not allowed for `%s', a global symbol with default"
" visibility, perhaps a declaration mixup?"),
input_bfd,
" not allowed for `%s', a global symbol with default"
" visibility, perhaps a declaration mixup?"),
input_bfd,
@@
-1662,12
+1665,12
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
to pass us these kinds of things. */
_bfd_error_handler
/* xgettext:c-format */
to pass us these kinds of things. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %A: relocation %s with non-zero addend %L
d"
- " against symbol `%s'"),
+ (_("%
pB, section %pA: relocation %s with non-zero adden
d"
+ "
%" PRId64 "
against symbol `%s'"),
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
- rel->r_addend,
+
(int64_t)
rel->r_addend,
symname[0] != '\0' ? symname : _("[whose name is lost]"));
bfd_set_error (bfd_error_bad_value);
symname[0] != '\0' ? symname : _("[whose name is lost]"));
bfd_set_error (bfd_error_bad_value);
@@
-1815,12
+1818,12
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
things. */
_bfd_error_handler
/* xgettext:c-format */
things. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %A: relocation %s with non-zero addend %L
d"
- " against symbol `%s'"),
+ (_("%
pB, section %pA: relocation %s with non-zero adden
d"
+ "
%" PRId64 "
against symbol `%s'"),
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
input_bfd,
input_section,
cris_elf_howto_table[r_type].name,
- rel->r_addend,
+
(int64_t)
rel->r_addend,
symname[0] != '\0' ? symname : _("[whose name is lost]"));
bfd_set_error (bfd_error_bad_value);
return FALSE;
symname[0] != '\0' ? symname : _("[whose name is lost]"));
bfd_set_error (bfd_error_bad_value);
return FALSE;
@@
-1949,7
+1952,7
@@
cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
{
_bfd_error_handler
/* xgettext:c-format */
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %
A: relocation %s is"
+ (_("%
pB, section %p
A: relocation %s is"
" not allowed for symbol: `%s'"
" which is defined outside the program,"
" perhaps a declaration mixup?"),
" not allowed for symbol: `%s'"
" which is defined outside the program,"
" perhaps a declaration mixup?"),
@@
-2477,7
+2480,7
@@
cris_elf_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED, const asection *plt,
if ((got = bfd_get_section_by_name (abfd, ".got")) == NULL)
return (bfd_vma) -1;
if ((got = bfd_get_section_by_name (abfd, ".got")) == NULL)
return (bfd_vma) -1;
- plt_sec_size = bfd_section_size (plt
->owner, plt
);
+ plt_sec_size = bfd_section_size (plt);
plt_entry_size
= (bfd_get_mach (abfd) == bfd_mach_cris_v32
? PLT_ENTRY_SIZE_V32 : PLT_ENTRY_SIZE);
plt_entry_size
= (bfd_get_mach (abfd) == bfd_mach_cris_v32
? PLT_ENTRY_SIZE_V32 : PLT_ENTRY_SIZE);
@@
-3044,7
+3047,7
@@
cris_elf_check_relocs (bfd *abfd,
{
_bfd_error_handler
/* xgettext:c-format */
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %A:\n
v10/v32 compatible object"
+ (_("%
pB, section %pA:
v10/v32 compatible object"
" must not contain a PIC relocation"),
abfd, sec);
return FALSE;
" must not contain a PIC relocation"),
abfd, sec);
return FALSE;
@@
-3098,7
+3101,7
@@
cris_elf_check_relocs (bfd *abfd,
{
_bfd_error_handler
/* xgettext:c-format */
{
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %
A:\n relocation %s not valid"
+ (_("%
pB, section %p
A:\n relocation %s not valid"
" in a shared object;"
" typically an option mixup, recompile with -fPIC"),
abfd,
" in a shared object;"
" typically an option mixup, recompile with -fPIC"),
abfd,
@@
-3316,7
+3319,7
@@
cris_elf_check_relocs (bfd *abfd,
/* FIXME: How do we make this optionally a warning only? */
_bfd_error_handler
/* xgettext:c-format */
/* FIXME: How do we make this optionally a warning only? */
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section %A:\n
relocation %s should not"
+ (_("%
pB, section %pA:
relocation %s should not"
" be used in a shared object; recompile with -fPIC"),
abfd,
sec,
" be used in a shared object; recompile with -fPIC"),
abfd,
sec,
@@
-3482,9
+3485,7
@@
cris_elf_check_relocs (bfd *abfd,
/* This relocation describes which C++ vtable entries are actually
used. Record for later use during GC. */
case R_CRIS_GNU_VTENTRY:
/* This relocation describes which C++ vtable entries are actually
used. Record for later use during GC. */
case R_CRIS_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;
return FALSE;
break;
@@
-3579,7
+3580,7
@@
elf_cris_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
/* It's OK to base decisions on the section name, because none
of the dynobj section names depend upon the input files. */
/* It's OK to base decisions on the section name, because none
of the dynobj section names depend upon the input files. */
- name = bfd_
get_section_name (dynobj,
s);
+ name = bfd_
section_name (
s);
if (strcmp (name, ".plt") == 0)
{
if (strcmp (name, ".plt") == 0)
{
@@
-3741,8
+3742,8
@@
elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *h,
/* FIXME: How do we make this optionally a warning only? */
_bfd_error_handler
/* xgettext:c-format */
/* FIXME: How do we make this optionally a warning only? */
_bfd_error_handler
/* xgettext:c-format */
- (_("%
B, section `%A', to symbol `%s':\n
"
- "
relocation %s should not be used"
+ (_("%
pB, section `%pA', to symbol `%s':
"
+ " relocation %s should not be used"
" in a shared object; recompile with -fPIC"),
s->section->owner,
s->section,
" in a shared object; recompile with -fPIC"),
s->section->owner,
s->section,
@@
-3828,9
+3829,8
@@
cris_elf_object_p (bfd *abfd)
/* Mark presence or absence of leading underscore. Set machine type
flags from mach type. */
/* Mark presence or absence of leading underscore. Set machine type
flags from mach type. */
-static void
-cris_elf_final_write_processing (bfd *abfd,
- bfd_boolean linker ATTRIBUTE_UNUSED)
+static bfd_boolean
+cris_elf_final_write_processing (bfd *abfd)
{
unsigned long e_flags = elf_elfheader (abfd)->e_flags;
{
unsigned long e_flags = elf_elfheader (abfd)->e_flags;
@@
-3854,10
+3854,11
@@
cris_elf_final_write_processing (bfd *abfd,
default:
_bfd_abort (__FILE__, __LINE__,
default:
_bfd_abort (__FILE__, __LINE__,
- _("
U
nexpected machine number"));
+ _("
u
nexpected machine number"));
}
elf_elfheader (abfd)->e_flags = e_flags;
}
elf_elfheader (abfd)->e_flags = e_flags;
+ return _bfd_elf_final_write_processing (abfd);
}
/* Set the mach type from e_flags value. */
}
/* Set the mach type from e_flags value. */
@@
-3955,8
+3956,8
@@
cris_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
{
_bfd_error_handler
(bfd_get_symbol_leading_char (ibfd) == '_'
{
_bfd_error_handler
(bfd_get_symbol_leading_char (ibfd) == '_'
- ? _("%B: uses _-prefixed symbols, but writing file with non-prefixed symbols")
- : _("%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"),
+ ? _("%
p
B: uses _-prefixed symbols, but writing file with non-prefixed symbols")
+ : _("%
p
B: uses non-prefixed symbols, but writing file with _-prefixed symbols"),
ibfd);
bfd_set_error (bfd_error_bad_value);
return FALSE;
ibfd);
bfd_set_error (bfd_error_bad_value);
return FALSE;
@@
-3975,9
+3976,9
@@
cris_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
{
_bfd_error_handler
((imach == bfd_mach_cris_v32)
{
_bfd_error_handler
((imach == bfd_mach_cris_v32)
- ? _("%B contains CRIS v32 code, incompatible"
+ ? _("%
p
B contains CRIS v32 code, incompatible"
" with previous objects")
" with previous objects")
- : _("%B contains non-CRIS-v32 code, incompatible"
+ : _("%
p
B contains non-CRIS-v32 code, incompatible"
" with previous objects"),
ibfd);
bfd_set_error (bfd_error_bad_value);
" with previous objects"),
ibfd);
bfd_set_error (bfd_error_bad_value);
This page took
0.028824 seconds
and
4
git commands to generate.