This is the mail archive of the binutils@sourceware.org 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]

Re: Feature request: improved build-id generation


On 03/15/2018 06:32 AM, Nick Clifton wrote:
Hi Mark,

That might be an interesting alternative. Could you use this for e.g.
inserting a .comment section fragment with an unique (version) string?
That would be stripped away, but should still count for the build-id
hash calculation.

If you know the value you want to store ahead of time, then it is easy:

   % cat comment.t
SECTIONS
{
	.comment (INFO) :
	{
		BYTE (0x12);
		BYTE (0x34);
		BYTE (0x56);
		BYTE (0x78);
	}
}

   % gcc hello.c -Wl,comment.t
   % readelf -x.comment a.out

Hex dump of section '.comment':
   0x00000000 4743433a 2028474e 55292037 2e332e31 GCC: (GNU) 7.3.1
   0x00000010 20323031 38303133 30202852 65642048  20180130 (Red H
   0x00000020 61742037 2e332e31 2d322900 4743433a at 7.3.1-2).GCC:
   0x00000030 2028474e 55292037 2e322e31 20323031  (GNU) 7.2.1 201
   0x00000040 37303931 35202852 65642048 61742037 70915 (Red Hat 7
   0x00000050 2e322e31 2d322900 12345678          .2.1-2)..4Vx

   (Note how the value has been appended to the .comment section).

   Unfortunately the linker does not have a STRING() operator to insert
   ascii codes into a section, so you have to construct the bytes by
   hand.  Eg:

   % cat comment.t
SECTIONS
{
	.comment (INFO) :
	{
		BYTE (0x41);
		BYTE (0x42);
		BYTE (0x43);
		BYTE (0x00);
	}
}

   % gcc hello.c -Wl,comment.t
   % readelf -p.comment a.out

String dump of section '.comment':
   [     0]  GCC: (GNU) 7.3.1 20180130 (Red Hat 7.3.1-2)
   [    2c]  GCC: (GNU) 7.2.1 20170915 (Red Hat 7.2.1-2)
   [    58]  ABC

   A simple perl or python script could be used to create the comment.t
   linker script fragment.

Cheers
   Nick


I think this approach looks promising. I'm going to see about prototyping
this approach.

Thanks,
Laura


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