This is the mail archive of the 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]

Gold Patch to fix ICF bug.


    I have attached a gold patch to fix an ICF bug due to common symbols.

Here is how to reproduce.

Create test.c (C file, not C++) :

int  a;
int  b;

void fn1(int p)
 a = p;
void fn2(int p)
 b = p;

int main()
  return 0;

$ gcc -fdata-sections -ffunction-sections
-Wl,--icf=safe,--print-icf-sections --save-temps test.c

ld: ICF folding section '.text.fn2' in file 'test.o'into '.text.fn1'
in file 'test.o'

fn1 and fn2 are folded which is obviously incorrect.

This is because a and b are common symbols and do not get a section.
gold sees the sections as unordinary and the relocs are not passed to
the ICF matching algorithm.

The attached patch fixes this problem. I have also made sure I pass
information on every relocation to the ICF matching algorithm.

	* gc.h (gc_process_relocs): Pass information on relocs pointing to
	sections that are not ordinary to icf.
	* (get_section_contents): Handle relocation pointing to section
	with no object or shndx information.
	* testsuite/ Remove
	* testsuite/ Regenerate.
	* testsuite/ Remove printf.
	* testsuite/ Delete file.


Attachment: icf_bug_fixes_patch.txt
Description: Text document

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