public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* elf-eh-frame.c unsigned ints
@ 2002-01-25  3:53 Alan Modra
  2002-01-25  4:13 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2002-01-25  3:53 UTC (permalink / raw)
  To: binutils; +Cc: Steve Munroe, Peter Bergner

powerpc64-linux-readelf -r libc.so
.
.
Relocation section '.rela.eh_frame' at offset 0x47ac0 contains 109 entries:
    Offset             Info            Type               Symbol's Value
00000000001c2140  0000000000000016 R_PPC_RELATIVE
00000001001c2178  0000000000000016 R_PPC_RELATIVE
00000001001c21c0  0000000000000016 R_PPC_RELATIVE
00000001001c21f8  0000000000000016 R_PPC_RELATIVE
00000001001c2230  0000000000000016 R_PPC_RELATIVE
.

Note the offsets!  Causes ld.so to crash of course.  Really, I think
it's a mistake to be using unsigned ints in various structures in
elf-eh-frame.c when bfd_vma is the correct type, but I'll leave that
fix to Jakub.  Meanwhile, removing parentheses causes the expression
to be evaluated as intended.

	* elf-eh-frame.c (_bfd_elf_eh_frame_section_offset): Avoid
	unsigned overflow when new_offset < old_offset.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: bfd/elf-eh-frame.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-eh-frame.c,v
retrieving revision 1.6
diff -u -p -r1.6 elf-eh-frame.c
--- elf-eh-frame.c	2002/01/04 17:02:30	1.6
+++ elf-eh-frame.c	2002/01/25 06:11:41
@@ -867,8 +867,8 @@ _bfd_elf_eh_frame_section_offset (output
 	      + sec_info->entry[mid].lsda_offset)))
     return (bfd_vma) -1;
 
-  return (offset
-	  + (sec_info->entry[mid].new_offset - sec_info->entry[mid].offset));
+  return (offset + sec_info->entry[mid].new_offset
+	  - sec_info->entry[mid].offset);
 }
 
 /* Write out .eh_frame section.  This is called with the relocated

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: elf-eh-frame.c unsigned ints
  2002-01-25  3:53 elf-eh-frame.c unsigned ints Alan Modra
@ 2002-01-25  4:13 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2002-01-25  4:13 UTC (permalink / raw)
  To: binutils, Steve Munroe, Peter Bergner

On Fri, Jan 25, 2002 at 04:53:58PM +1030, Alan Modra wrote:
> powerpc64-linux-readelf -r libc.so
> .
> .
> Relocation section '.rela.eh_frame' at offset 0x47ac0 contains 109 entries:
>     Offset             Info            Type               Symbol's Value
> 00000000001c2140  0000000000000016 R_PPC_RELATIVE
> 00000001001c2178  0000000000000016 R_PPC_RELATIVE
> 00000001001c21c0  0000000000000016 R_PPC_RELATIVE
> 00000001001c21f8  0000000000000016 R_PPC_RELATIVE
> 00000001001c2230  0000000000000016 R_PPC_RELATIVE
> .
> 
> Note the offsets!  Causes ld.so to crash of course.  Really, I think
> it's a mistake to be using unsigned ints in various structures in
> elf-eh-frame.c when bfd_vma is the correct type, but I'll leave that
> fix to Jakub.

I used them because .eh_frame section cannot be bigger than 4GB anyway.
If it is used somewhere to represent something other than offsets from start
of .eh_frame section, then it is of course a bug.

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-25  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-25  3:53 elf-eh-frame.c unsigned ints Alan Modra
2002-01-25  4:13 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).