name = _bfd_coff_internal_syment_name (abfd, in, namebuf);
if (name == NULL)
{
- _bfd_error_handler (_("%B: unable to find name for empty section"),
+ _bfd_error_handler (_("%pB: unable to find name for empty section"),
abfd);
bfd_set_error (bfd_error_invalid_target);
return;
name = (const char *) bfd_alloc (abfd, strlen (namebuf) + 1);
if (name == NULL)
{
- _bfd_error_handler (_("%B: out of memory creating name for empty section"),
+ _bfd_error_handler (_("%pB: out of memory creating name for empty section"),
abfd);
return;
}
sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
if (sec == NULL)
{
- _bfd_error_handler (_("%B: unable to create fake empty section"),
+ _bfd_error_handler (_("%pB: unable to create fake empty section"),
abfd);
return;
}
{
/* xgettext:c-format */
_bfd_error_handler
- (_("%B: aout header specifies an invalid number of data-directory entries: %ld"),
+ (_("%pB: aout header specifies an invalid number of data-directory entries: %ld"),
abfd, a->NumberOfRvaAndSizes);
bfd_set_error (bfd_error_bad_value);
typedef struct
{
- const char * section_name;
+ char section_name[SCNNMLEN];
unsigned long must_have;
}
pe_required_section_flags;
{ ".text" , IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE },
{ ".tls", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_WRITE },
{ ".xdata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
- { NULL, 0}
};
pe_required_section_flags * p;
by ld --enable-auto-import (if auto-import is actually needed),
by ld --omagic, or by obcopy --writable-text. */
- for (p = known_sections; p->section_name; p++)
- if (strcmp (scnhdr_int->s_name, p->section_name) == 0)
+ for (p = known_sections;
+ p < known_sections + ARRAY_SIZE (known_sections);
+ p++)
+ if (memcmp (scnhdr_int->s_name, p->section_name, SCNNMLEN) == 0)
{
- if (strcmp (scnhdr_int->s_name, ".text")
+ if (memcmp (scnhdr_int->s_name, ".text", sizeof ".text")
|| (bfd_get_file_flags (abfd) & WP_TEXT))
scnhdr_int->s_flags &= ~IMAGE_SCN_MEM_WRITE;
scnhdr_int->s_flags |= p->must_have;
if (coff_data (abfd)->link_info
&& ! bfd_link_relocatable (coff_data (abfd)->link_info)
&& ! bfd_link_pic (coff_data (abfd)->link_info)
- && strcmp (scnhdr_int->s_name, ".text") == 0)
+ && memcmp (scnhdr_int->s_name, ".text", sizeof ".text") == 0)
{
/* By inference from looking at MS output, the 32 bit field
which is the combination of the number_of_relocs and
else
{
/* xgettext:c-format */
- _bfd_error_handler (_("%B: line number overflow: 0x%lx > 0xffff"),
+ _bfd_error_handler (_("%pB: line number overflow: 0x%lx > 0xffff"),
abfd, scnhdr_int->s_nlnno);
bfd_set_error (bfd_error_file_truncated);
H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nlnno);
if (hint_addr == 0)
hint_addr = first_thunk;
- if (hint_addr != 0)
+ if (hint_addr != 0 && hint_addr - adj < datasize)
{
bfd_byte *ft_data;
asection *ft_section;
dataoff = addr - section->vma;
datasize = extra->DataDirectory[PE_EXPORT_TABLE].Size;
- if (datasize > section->size - dataoff)
+ if (dataoff > section->size
+ || datasize > section->size - dataoff)
{
fprintf (file,
_("\nThere is an export table in %s, but it does not fit into that section\n"),
}
/* PR 17512: Handle corrupt PE binaries. */
- if (datasize < 36)
+ if (datasize < 40)
{
fprintf (file,
/* xgettext:c-format */
edt.base);
/* PR 17512: Handle corrupt PE binaries. */
- if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize
+ /* PR 17512 file: 140-165018-0.004. */
+ if (edt.eat_addr - adj >= datasize
/* PR 17512: file: 092b1829 */
- || (edt.num_functions * 4) < edt.num_functions
- /* PR 17512 file: 140-165018-0.004. */
- || data + edt.eat_addr - adj < data)
+ || (edt.num_functions + 1) * 4 < edt.num_functions
+ || edt.eat_addr - adj + (edt.num_functions + 1) * 4 > datasize)
fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
(long) edt.eat_addr,
(long) edt.num_functions);
if ((stop % onaline) != 0)
fprintf (file,
/* xgettext:c-format */
- _("Warning, .pdata section size (%ld) is not a multiple of %d\n"),
+ _("warning, .pdata section size (%ld) is not a multiple of %d\n"),
(long) stop, onaline);
fprintf (file,
if ((stop % onaline) != 0)
fprintf (file,
/* xgettext:c-format */
- _("Warning, .pdata section size (%ld) is not a multiple of %d\n"),
+ _("warning, .pdata section size (%ld) is not a multiple of %d\n"),
(long) stop, onaline);
fprintf (file,
> bfd_get_section_size (section))
{
/* xgettext:c-format */
- _bfd_error_handler (_("%B: Data Directory size (%lx) exceeds space left in section (%Lx)"),
- obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size,
- bfd_get_section_size (section) - (addr - section->vma));
+ _bfd_error_handler
+ (_("%pB: Data Directory size (%lx) "
+ "exceeds space left in section (%" PRIx64 ")"),
+ obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size,
+ (uint64_t) (section->size - (addr - section->vma)));
+ return FALSE;
+ }
+ /* PR 23110. */
+ else if (ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size < 0)
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler
+ (_("%pB: Data Directory size (%#lx) is negative"),
+ obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size);
return FALSE;
}
if (!bfd_set_section_contents (obfd, section, data, 0, section->size))
{
- _bfd_error_handler (_("Failed to update file offsets in debug directory"));
+ _bfd_error_handler (_("failed to update file offsets in debug directory"));
return FALSE;
}
}
else if (section)
{
- _bfd_error_handler (_("%B: Failed to read debug data section"), obfd);
+ _bfd_error_handler (_("%pB: failed to read debug data section"), obfd);
return FALSE;
}
}
if (adir->characteristics != bdir->characteristics)
{
- _bfd_error_handler (_(".rsrc merge failure: dirs with differing characteristics\n"));
+ _bfd_error_handler (_(".rsrc merge failure: dirs with differing characteristics"));
bfd_set_error (bfd_error_file_truncated);
return;
}
if (adir->major != bdir->major || adir->minor != bdir->minor)
{
- _bfd_error_handler (_(".rsrc merge failure: differing directory versions\n"));
+ _bfd_error_handler (_(".rsrc merge failure: differing directory versions"));
bfd_set_error (bfd_error_file_truncated);
return;
}
if (data > dataend)
{
/* Corrupted .rsrc section - cannot merge. */
- _bfd_error_handler (_("%B: .rsrc merge failure: corrupt .rsrc section"),
+ _bfd_error_handler (_("%pB: .rsrc merge failure: corrupt .rsrc section"),
abfd);
bfd_set_error (bfd_error_file_truncated);
goto end;
if ((data - p) > rsrc_sizes [num_resource_sets])
{
- _bfd_error_handler (_("%B: .rsrc merge failure: unexpected .rsrc size"),
+ _bfd_error_handler (_("%pB: .rsrc merge failure: unexpected .rsrc size"),
abfd);
bfd_set_error (bfd_error_file_truncated);
goto end;
else
{
_bfd_error_handler
- (_("%B: unable to fill in DataDictionary[1] because .idata$2 is missing"),
+ (_("%pB: unable to fill in DataDictionary[1] because .idata$2 is missing"),
abfd);
result = FALSE;
}
else
{
_bfd_error_handler
- (_("%B: unable to fill in DataDictionary[1] because .idata$4 is missing"),
+ (_("%pB: unable to fill in DataDictionary[1] because .idata$4 is missing"),
abfd);
result = FALSE;
}
else
{
_bfd_error_handler
- (_("%B: unable to fill in DataDictionary[12] because .idata$5 is missing"),
+ (_("%pB: unable to fill in DataDictionary[12] because .idata$5 is missing"),
abfd);
result = FALSE;
}
else
{
_bfd_error_handler
- (_("%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)] because .idata$6 is missing"),
+ (_("%pB: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)] because .idata$6 is missing"),
abfd);
result = FALSE;
}
else
{
_bfd_error_handler
- (_("%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)]"
+ (_("%pB: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)]"
" because .idata$6 is missing"), abfd);
result = FALSE;
}
else
{
_bfd_error_handler
- (_("%B: unable to fill in DataDictionary[9] because __tls_used is missing"),
+ (_("%pB: unable to fill in DataDictionary[9] because __tls_used is missing"),
abfd);
result = FALSE;
}