RFC: readelf: Explain why LLVM bitcode files cannot be read

Richard Earnshaw Richard.Earnshaw@foss.arm.com
Tue Aug 23 15:26:33 GMT 2022



On 22/08/2022 11:18, Nick Clifton via Binutils wrote:
> Hi Jeff,
> 
>> I think the same issue arises with golang -- its .o files are not ELF, 
>> but can be read by the golang variants of objdump, nm, etc. So you 
>> might want to look at doing something similar for golang as well.
> 
> A great idea.  I have recoded the patch to create a new function
> which checks the magic number, and if it is not ELF then it tests
> for LLVM bitcode files and golang object files.  This time I have
> put the magic numbers into a static array, so it should be easy to
> add more sequences should we wish to do so.
> 
> Cheers
>    Nick
> 
> 

This fails to build on ubuntu (which defaults to -Werror=format-security):

/home/rearnsha/gnusrc/gcc-cross/master/binutils/readelf.c: In function 
‘check_magic_number’:
/home/rearnsha/gnusrc/gcc-cross/master/binutils/readelf.c:5738:6: error: 
format not a string literal and no format arguments 
[-Werror=format-security]
  5738 |      error (known_magic[i].ar_message);
       |      ^~~~~
/home/rearnsha/gnusrc/gcc-cross/master/binutils/readelf.c:5740:6: error: 
format not a string literal and no format arguments 
[-Werror=format-security]
  5740 |      error (known_magic[i].obj_message);
       |      ^~~~~

You need to pass the output of those strings as a parameter to "%s".


More information about the Binutils mailing list