[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/18514] New: elfutils reports '.plt' size not multiple of entry s
From: |
deller at gmx dot de |
Subject: |
[Bug ld/18514] New: elfutils reports '.plt' size not multiple of entry size |
Date: |
Wed, 10 Jun 2015 20:02:20 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=18514
Bug ID: 18514
Summary: elfutils reports '.plt' size not multiple of entry
size
Product: binutils
Version: unspecified
URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=7539
81
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: deller at gmx dot de
CC: dave.anglin at bell dot net
Target Milestone: ---
Target: hppa
Created attachment 8357
--> https://sourceware.org/bugzilla/attachment.cgi?id=8357&action=edit
possible patch
(This bug report is brought upstream because of debian bug
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753981 )
The elfutils of the elfutils-0.159 package do a validation of the sh_entsize
field in sections.
This check is in [elfutils]/libelf/elf32_updatenull.c Line ~ 373:
/* Check that the section size is actually a multiple of
the entry size. */
if (shdr->sh_entsize != 0
&& unlikely (shdr->sh_size % shdr->sh_entsize != 0)
&& (elf->flags & ELF_F_PERMISSIVE) == 0)
{
__libelf_seterrno (ELF_E_INVALID_SHENTSIZE);
return -1;
}
with gdb I could get the values of the variables (the error happens twice, so I
put in two lines here):
(gdb) p *shdr
$3 = {sh_name = 133, sh_type = 8, sh_flags = 7, sh_addr = 113608, sh_offset =
352, sh_size = 1108, sh_link = 0, sh_info = 0, sh_addralign = 4, sh_entsize =
8}
(gdb) p *shdr
$1 = {sh_name = 249, sh_type = 1, sh_flags = 7, sh_addr = 113608, sh_offset =
48072, sh_size = 1108, sh_link = 0, sh_info = 0, sh_addralign = 4, sh_entsize =
8}
sh_entsize gets set to 8 by binutils in /bfd/elf32-hppa.c via sh_entsize =
PLT_ENTRY_SIZE (==8).
The check above now starts to fail on hppa binaries, since sh_size (e.g. 1108)
is not a multiple of sh_entsize (=8). Reason for that is that in
bfd/elf32-hppa.c adds plt stubs to the plt section which are not a multiple of
8 in size themselves.
This patch seems to resolve that issue:
diff -up ./bfd/elf32-hppa.c.org ./bfd/elf32-hppa.c
--- ./bfd/elf32-hppa.c.org 2015-06-10 14:53:04.458322013 +0200
+++ ./bfd/elf32-hppa.c 2015-06-10 18:03:27.216795894 +0200
@@ -4581,9 +4581,11 @@ elf32_hppa_finish_dynamic_sections (bfd
if (htab->splt != NULL && htab->splt->size != 0)
{
- /* Set plt entry size. */
+ /* Set plt entry size to 0 instead of PLT_ENTRY_SIZE, since we add the
+ plt stubs and as such the section does not hold a table of fixed-size
+ entries. */
elf_section_data (htab->splt->output_section)
- ->this_hdr.sh_entsize = PLT_ENTRY_SIZE;
+ ->this_hdr.sh_entsize = 0;
if (htab->need_plt_stub)
{
Is this a reasonable patch ?
Or would the value "4" be more correct here?
Or should the check in elfutils better be revised?
Thanks,
Helge
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/18514] New: elfutils reports '.plt' size not multiple of entry size,
deller at gmx dot de <=