Ensure that when attempting to process an ARM Mach-O file with unknown relocs, that a suitable error message is displayed.
PR 24703 binutils* bucomm.c (bfd_nonfatal): If no bfd error code has been set then indicate this in the output. (bfd_nonfatal_message): Likewise. bfd * mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add error messages for failures. * mach-o.c (bfd_mach_o_canonicalize_relocs): Set an bfd error code if returning an error value.
This commit is contained in:
parent
762c164d75
commit
a68aa5d302
@ -1,3 +1,11 @@
|
|||||||
|
2019-06-26 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR 24703
|
||||||
|
* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add error
|
||||||
|
messages for failures.
|
||||||
|
* mach-o.c (bfd_mach_o_canonicalize_relocs): Set an bfd error code
|
||||||
|
if returning an error value.
|
||||||
|
|
||||||
2019-06-25 Jan Beulich <jbeulich@suse.com>
|
2019-06-25 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
* elf-properties.c (elf_find_and_remove_property): Rename last
|
* elf-properties.c (elf_find_and_remove_property): Rename last
|
||||||
|
@ -156,7 +156,10 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
bfd_mach_o_reloc_info reloc;
|
bfd_mach_o_reloc_info reloc;
|
||||||
|
|
||||||
if (!bfd_mach_o_pre_canonicalize_one_reloc (abfd, raw, &reloc, res, syms))
|
if (!bfd_mach_o_pre_canonicalize_one_reloc (abfd, raw, &reloc, res, syms))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "ARm 1\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (reloc.r_scattered)
|
if (reloc.r_scattered)
|
||||||
{
|
{
|
||||||
@ -165,7 +168,11 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
case BFD_MACH_O_ARM_RELOC_PAIR:
|
case BFD_MACH_O_ARM_RELOC_PAIR:
|
||||||
/* PR 21813: Check for a corrupt PAIR reloc at the start. */
|
/* PR 21813: Check for a corrupt PAIR reloc at the start. */
|
||||||
if (res == res_base)
|
if (res == res_base)
|
||||||
|
{
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM reloc pair: reloc is first reloc"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
if (reloc.r_length == 2)
|
if (reloc.r_length == 2)
|
||||||
{
|
{
|
||||||
res->howto = &arm_howto_table[7];
|
res->howto = &arm_howto_table[7];
|
||||||
@ -178,6 +185,8 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
res->address = res[-1].address;
|
res->address = res[-1].address;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM reloc pair: invalid length: %d"), reloc.r_length);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
case BFD_MACH_O_ARM_RELOC_SECTDIFF:
|
case BFD_MACH_O_ARM_RELOC_SECTDIFF:
|
||||||
@ -191,6 +200,8 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
res->howto = &arm_howto_table[8];
|
res->howto = &arm_howto_table[8];
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM sectdiff reloc: invalid length: %d"), reloc.r_length);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
case BFD_MACH_O_ARM_RELOC_LOCAL_SECTDIFF:
|
case BFD_MACH_O_ARM_RELOC_LOCAL_SECTDIFF:
|
||||||
@ -204,6 +215,9 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
res->howto = &arm_howto_table[9];
|
res->howto = &arm_howto_table[9];
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM local sectdiff reloc: invalid length: %d"),
|
||||||
|
reloc.r_length);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
case BFD_MACH_O_ARM_RELOC_HALF_SECTDIFF:
|
case BFD_MACH_O_ARM_RELOC_HALF_SECTDIFF:
|
||||||
@ -216,6 +230,9 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
res->howto = &arm_howto_table[14];
|
res->howto = &arm_howto_table[14];
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM half sectdiff reloc: invalid length: %d"),
|
||||||
|
reloc.r_length);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -245,6 +262,9 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
res->howto = &arm_howto_table[3];
|
res->howto = &arm_howto_table[3];
|
||||||
return TRUE;
|
return TRUE;
|
||||||
default:
|
default:
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM vanilla reloc: invalid length: %d (pcrel: %d)"),
|
||||||
|
reloc.r_length, reloc.r_pcrel);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -306,6 +326,8 @@ bfd_mach_o_arm_canonicalize_one_reloc (bfd * abfd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o ARM reloc: unknown reloc type: %d"), reloc.r_length);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
bfd/mach-o.c
13
bfd/mach-o.c
@ -1501,7 +1501,11 @@ bfd_mach_o_canonicalize_non_scattered_reloc (bfd *abfd,
|
|||||||
{
|
{
|
||||||
/* PR 17512: file: 006-2964-0.004. */
|
/* PR 17512: file: 006-2964-0.004. */
|
||||||
if (num > mdata->nsects)
|
if (num > mdata->nsects)
|
||||||
return FALSE;
|
{
|
||||||
|
_bfd_error_handler (_("\
|
||||||
|
malformed mach-o reloc: section index is greater than the number of sections"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* A section number. */
|
/* A section number. */
|
||||||
sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr;
|
sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr;
|
||||||
@ -1609,7 +1613,7 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos,
|
|||||||
{
|
{
|
||||||
bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
|
bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
struct mach_o_reloc_info_external *native_relocs;
|
struct mach_o_reloc_info_external *native_relocs = NULL;
|
||||||
bfd_size_type native_size;
|
bfd_size_type native_size;
|
||||||
|
|
||||||
/* Allocate and read relocs. */
|
/* Allocate and read relocs. */
|
||||||
@ -1617,7 +1621,7 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos,
|
|||||||
|
|
||||||
/* PR 17512: file: 09477b57. */
|
/* PR 17512: file: 09477b57. */
|
||||||
if (native_size < count)
|
if (native_size < count)
|
||||||
return -1;
|
goto err;
|
||||||
|
|
||||||
native_relocs =
|
native_relocs =
|
||||||
(struct mach_o_reloc_info_external *) bfd_malloc (native_size);
|
(struct mach_o_reloc_info_external *) bfd_malloc (native_size);
|
||||||
@ -1636,8 +1640,11 @@ bfd_mach_o_canonicalize_relocs (bfd *abfd, unsigned long filepos,
|
|||||||
}
|
}
|
||||||
free (native_relocs);
|
free (native_relocs);
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
free (native_relocs);
|
free (native_relocs);
|
||||||
|
if (bfd_get_error () == bfd_error_no_error)
|
||||||
|
bfd_set_error (bfd_error_invalid_operation);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2019-06-26 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR 24703
|
||||||
|
* bucomm.c (bfd_nonfatal): If no bfd error code has been set then
|
||||||
|
indicate this in the output.
|
||||||
|
(bfd_nonfatal_message): Likewise.
|
||||||
|
|
||||||
2019-06-25 Jan Beulich <jbeulich@suse.com>
|
2019-06-25 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
* readelf.c (dump_ctf_indent_lines): Rename local variable
|
* readelf.c (dump_ctf_indent_lines): Rename local variable
|
||||||
|
@ -44,8 +44,12 @@ void
|
|||||||
bfd_nonfatal (const char *string)
|
bfd_nonfatal (const char *string)
|
||||||
{
|
{
|
||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
|
enum bfd_error err = bfd_get_error ();
|
||||||
|
|
||||||
errmsg = bfd_errmsg (bfd_get_error ());
|
if (err == bfd_error_no_error)
|
||||||
|
errmsg = _("cause of error unknown");
|
||||||
|
else
|
||||||
|
errmsg = bfd_errmsg (err);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
if (string)
|
if (string)
|
||||||
fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
|
fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
|
||||||
@ -74,8 +78,12 @@ bfd_nonfatal_message (const char *filename,
|
|||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
const char *section_name;
|
const char *section_name;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
enum bfd_error err = bfd_get_error ();
|
||||||
|
|
||||||
errmsg = bfd_errmsg (bfd_get_error ());
|
if (err == bfd_error_no_error)
|
||||||
|
errmsg = _("cause of error unknown");
|
||||||
|
else
|
||||||
|
errmsg = bfd_errmsg (err);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
section_name = NULL;
|
section_name = NULL;
|
||||||
va_start (args, format);
|
va_start (args, format);
|
||||||
|
Loading…
Reference in New Issue
Block a user