Bug 24703 - objcopy fails --prefix-symbols with no error
Summary: objcopy fails --prefix-symbols with no error
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-19 09:01 UTC by raulf
Modified: 2019-06-26 16:06 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2019-06-26 00:00:00


Attachments
obj files (3.82 KB, application/octet-stream)
2019-06-19 09:01 UTC, raulf
Details
This obj file works well. (1.54 KB, application/octet-stream)
2019-06-19 09:03 UTC, raulf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description raulf 2019-06-19 09:01:09 UTC
Created attachment 11846 [details]
obj files

Hi there,

   I've installed binutils 2.31 via homebrew on Mac os Mojave 10.14.2.
   
   I've checked the .o file by: `lipo -info a_enum.o`,
and it print out: 
`Non-fat file: a_enum.o is architecture: armv7`. 

then I tried to change symbol prefix name by:
`gobjcopy --prefix-symbols rong a_enum.o`
and it print out:
`gobjcopy: a_enum.o: no error`

But symbol table for a_enum.o don't change.

and when I typed in console:
`objdump -t a_enum.o`
it print out:
`a_enum.o:     file format Mach-O arm`

SYMBOL TABLE:
000000b4 g     F __TEXT,__text	_ASN1_ENUMERATED_get
00000000 g     F __TEXT,__text	_ASN1_ENUMERATED_set
000001c4 g     F __TEXT,__text	_ASN1_ENUMERATED_to_BN
00000124 g     F __TEXT,__text	_BN_to_ASN1_ENUMERATED
00000000         *UND*	_ASN1_STRING_free
00000000         *UND*	_ASN1_STRING_type_new
00000000         *UND*	_BN_bin2bn
00000000         *UND*	_BN_bn2bin
00000000         *UND*	_BN_is_negative
00000000         *UND*	_BN_num_bits
00000000         *UND*	_BN_set_negative
00000000         *UND*	_ERR_put_error
00000000         *UND*	_OPENSSL_free
00000000         *UND*	_OPENSSL_malloc
00000000         *UND*	_OPENSSL_realloc
00000000         *UND*	___stack_chk_fail
00000000         *UND*	___stack_chk_guard

BTW, I used clang to produce the a_enum.o file and it worked for some .o file, but didn't for others like a_enum.o.
Comment 1 raulf 2019-06-19 09:03:12 UTC
Created attachment 11847 [details]
This obj file works well.
Comment 2 Nick Clifton 2019-06-26 15:54:38 UTC
Hi Raulf,

  Thanks for reporting this bug.  There are actually two problems.
  The first is this message: "gobjcopy: a_enum.o: no error".  That
  is wrong.  That actually was an error, and this error prevented
  the symbol prefixing from happening.

  The second problem is that there is something wrong with the object
  file that you are trying to modify.  The gobjcopy program is unable
  to process the relocs inside it, and this is why an error should
  have been reported.  Actually it is also likely that the file itself
  is fine, but that it contains relocs that the gobjcopy program does
  not recognise.

  I am applying a patch which will add in a more informative error
  message:

   % gobjcopy --prefix-symbols rong a_enum.o
   gobjcopy: malformed mach-o ARM reloc pair: invalid length: 3
   gobjcopy: a_enum.o: invalid operation

  This does not resolve the underlying problem of whether or not the
  relocs inside a_enum.o are correct or not, but since I am not a
  Mach-O expert, I cannot make that decision.

Cheers
  Nick
Comment 3 Sourceware Commits 2019-06-26 16:05:43 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a68aa5d3020948564ef99d704d27e458ba22ad9d

commit a68aa5d3020948564ef99d704d27e458ba22ad9d
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Jun 26 17:03:32 2019 +0100

    Ensure that when attempting to process an ARM Mach-O file with unknown relocs, that a suitable error message is displayed.
    
    	PR 24703
    binutils* bucomm.c (bfd_nonfatal): If no bfd error code has been set then
    	indicate this in the output.
    	(bfd_nonfatal_message): Likewise.
    
    bfd	* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add error
    	messages for failures.
    	* mach-o.c (bfd_mach_o_canonicalize_relocs): Set an bfd error code
    	if returning an error value.
Comment 4 Nick Clifton 2019-06-26 16:06:12 UTC
Patch applied.