This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

elf-eh-frame.c unsigned ints


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]