[PATCH] elf: Also check linked-to section for SHT_NOTE section

Nick Clifton nickc@redhat.com
Wed Sep 30 14:01:18 GMT 2020


Hi H.J.

  Thanks for taking an interest in this.

> Please try this patch.
  It did not appear to make a difference. :-(

  I am using an extended test case (attached) but the results are the
  same as before:

  % as eliminate.s -o eliminate.o
  % ld -e 0 --gc-sections --print-gc-sections eliminate.o 
  ld: removing unused section '.group' in file 'eliminate.o'
  ld: removing unused section '.group' in file 'eliminate.o'
  ld: removing unused section '.text' in file 'eliminate.o'
  ld: removing unused section '.unused1' in file 'eliminate.o'
  ld: removing unused section '.unused2[unused_group]' in file 'eliminate.o'
  ld: removing unused section '.unused3[unused_group2]' in file 'eliminate.o'
  ld: removing unused section '.gnu.note2[unused_group]' in file 'eliminate.o'
  ld: removing unused section '.gnu.note3[unused_group2]' in file 'eliminate.o'
  ld: a.out: sh_link of section `.gnu.note1' points to discarded section `.unused1' of `eliminate.o'
  ld: final link failed: bad value

Cheers
  Nick
-------------- next part --------------
	.text
	.nop
	
	.section .unused1, "ax", %progbits
	.nop
	
	.section .unused2, "axG", %progbits, unused_group
	.nop

	.section .unused3, "axG", %progbits, unused_group2
	.nop
	
	.section .gnu.note.text, "", %note
	.word 1

	.section .gnu.note1, "o", %note, .unused1
	.word 2

	.section .gnu.note2, "G", %note, unused_group
	.word 3

	.section .gnu.note3, "oG", %note, .unused3, unused_group2
	.word 4


More information about the Binutils mailing list