Leading character for BINARY format ?
Nick Clifton
nickc@cygnus.com
Mon Apr 17 11:15:00 GMT 2000
Hi Guys
A customer reported a problem when using OBJCOPY to convert from
BINARY to ELF formats. The problem was that the target ELF format
did not use an underscore prefix for user symbols, but the symbols
generated by the BINARY code did. As a result they ended up with an
ELF executable with user symbols that had an underscore prefix.
Using the '--remove-leading-char' option to objcopy did not work
because the binary format does not define a leading character.
The patch below solves this problem for the customer, but I am not
entirely sure if might not have some unexpected side effects. All
that the patch does is to change the specification of the leading
character for the BINARY format from nothing to an underscore, so
that converting from BINARY to (ARM-) ELF with --remove-leading-char
will now strip the first character.
Is this patch OK to apply ?
Example:
% cat foo.c
int symbol;
% gcc -c foo.c
% objcopy -O binary foo.o foo.bin
% objcopy -I binary -O elf32-littlearm foo.bin foo.elf1
% objcopy -I binary -O elf32-littlearm --remove-leading-char foo.bin foo.elf2
% nm foo.o foo.elf1 foo.elf2
foo.o:
00000000 t .gcc2_compiled.
00000004 C symbol
foo.elf1:
00000000 D _binary_fred_bin_end
00000000 A _binary_fred_bin_size
00000000 D _binary_fred_bin_start
foo.elf2:
00000000 D binary_fred_bin_end
00000000 A binary_fred_bin_size
00000000 D binary_fred_bin_start
Cheers
Nick
2000-04-17 Nick Clifton <nickc@cygnus.com>
* binary.c (binary_vec): Change leading symbol from nul to
underscore.
Index: bfd/binary.c
===================================================================
RCS file: /cvs/src//src/bfd/binary.c,v
retrieving revision 1.3
diff -p -r1.3 binary.c
*** binary.c 1999/07/19 14:55:15 1.3
--- binary.c 2000/04/17 18:07:00
*************** const bfd_target binary_vec =
*** 344,350 ****
EXEC_P, /* object_flags */
(SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
| SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
! 0, /* symbol_leading_char */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
--- 344,350 ----
EXEC_P, /* object_flags */
(SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
| SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
! '_', /* symbol_leading_char */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
More information about the Binutils
mailing list