This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Support ELF64 on 32bit hosts
- To: binutils at sourceware dot cygnus dot com
- Subject: PATCH: Support ELF64 on 32bit hosts
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Mon, 20 Aug 2001 11:25:15 -0700
On 32bit hosts, when I did
# readelf -r foo.o
on an ELF/alpha file, I got
Relocation section '.rela.text' at offset 0x4a0 contains 4 entries:
Offset Info Type Symbol's Value Symbol's Name Addend
00000000 00006 R_ALPHA_GPDISP 0000000000000000 .debug_line + 4
00000018 00004 R_ALPHA_LITERAL 0000000000000004 x + 0
0000001c 00004 R_ALPHA_LITERAL 0000000000000004 x + 0
0000002c 00004 R_ALPHA_LITERAL 0000000000000004 x + 0
With this patch, I got
# readelf -r foo.o
Starting program: /export/build/gnu/binutils/build-full-i686-linux/binutils/readelf -r foo.o
Relocation section '.rela.text' at offset 0x4a0 contains 4 entries:
Offset Info Type Symbol's Value Symbol's Name Addend
0000000000000000 0000000500000006 R_ALPHA_GPDISP 0000000000000000 .debug_line + 4
0000000000000018 0000000800000004 R_ALPHA_LITERAL 0000000000000004 x + 0
000000000000001c 0000000800000004 R_ALPHA_LITERAL 0000000000000004 x + 0
000000000000002c 0000000800000004 R_ALPHA_LITERAL 0000000000000004 x + 0
H.J.
------
2001-08-20 H.J. Lu <hjl@gnu.org>
* readelf.c (dump_relocations): Support ELF64 on 32bit hosts.
(display_debug_info): Cast for 64bit hosts.
(display_debug_frames): Likewise.
(process_mips_specific): Likewise.
Index: readelf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/readelf.c,v
retrieving revision 1.63
diff -u -p -r1.63 readelf.c
--- readelf.c 2001/08/10 17:02:46 1.63
+++ readelf.c 2001/08/20 18:20:21
@@ -810,12 +810,24 @@ dump_relocations (file, rel_offset, rel_
return 0;
}
- if (is_rela)
- printf
- (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
+ if (is_32bit_elf)
+ {
+ if (is_rela)
+ printf
+ (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
+ else
+ printf
+ (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
+ }
else
- printf
- (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
+ {
+ if (is_rela)
+ printf
+ (_(" Offset Info Type Symbol's Value Symbol's Name Addend\n"));
+ else
+ printf
+ (_(" Offset Info Type Symbol's Value Symbol's Name\n"));
+ }
for (i = 0; i < rel_size; i++)
{
@@ -855,11 +867,26 @@ dump_relocations (file, rel_offset, rel_
#endif
}
+ if (is_32bit_elf)
+ {
#ifdef _bfd_int64_low
- printf (" %8.8lx %5.5lx ", _bfd_int64_low (offset), _bfd_int64_low (info));
+ printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset), _bfd_int64_low (info));
#else
- printf (" %8.8lx %5.5lx ", offset, info);
+ printf ("%8.8lx %8.8lx ", offset, info);
#endif
+ }
+ else
+ {
+#ifdef _bfd_int64_low
+ printf ("%8.8lx%8.8lx %8.8lx%8.8lx ",
+ _bfd_int64_high (offset),
+ _bfd_int64_low (offset),
+ _bfd_int64_high (info),
+ _bfd_int64_low (info));
+#else
+ printf ("%16.16lx %16.16lx ", offset, info);
+#endif
+ }
switch (elf_header.e_machine)
{
@@ -7189,8 +7216,9 @@ display_debug_info (section, start, file
return 0;
}
- printf (_(" <%d><%x>: Abbrev Number: %lu (%s)\n"),
- level, tags - section_begin - bytes_read,
+ printf (_(" <%d><%lx>: Abbrev Number: %lu (%s)\n"),
+ level,
+ (unsigned long) (tags - section_begin - bytes_read),
abbrev_number,
get_TAG_name (entry->tag));
@@ -7609,10 +7637,10 @@ display_debug_frames (section, start, fi
start += augmentation_data_len;
}
- printf ("\n%08lx %08lx %08lx FDE cie=%08x pc=%08lx..%08lx\n",
+ printf ("\n%08lx %08lx %08lx FDE cie=%08lx pc=%08lx..%08lx\n",
(unsigned long)(saved_start - section_start), length, cie_id,
- cie->chunk_start - section_start, fc->pc_begin,
- fc->pc_begin + fc->pc_range);
+ (unsigned long)(cie->chunk_start - section_start),
+ fc->pc_begin, fc->pc_begin + fc->pc_range);
if (! do_debug_frames_interp && augmentation_data_len)
{
unsigned long i;
@@ -8511,7 +8539,8 @@ process_mips_specific (file)
free (econf64);
}
- printf (_("\nSection '.conflict' contains %d entries:\n"), conflictsno);
+ printf (_("\nSection '.conflict' contains %ld entries:\n"),
+ (long) conflictsno);
puts (_(" Num: Index Value Name"));
for (cnt = 0; cnt < conflictsno; ++cnt)