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] |
Hi, I found a bug in ICF where it incorrectly inlines strings pointed to by SHT_REL relocation types. These relocation types encode the addend info at the relocation offset in the text section and ICF simply ignores them. Here is a simple example showing the bug. test_1.cc ---------- #include <string> std::string name1() { return "Name1"; } std::string bar() { return "AAAAAA"; } int main() { return 0; } test_2.cc ---------- #include <string> std::string name2() { return "Name2"; } std::string foo() { return "AAAAAA"; } $ gcc -ffunction-sections -fdata-sections -Wl,--print-icf-sections,--icf=all -O2 ld: ICF folding section '.text._Z5name2v' in file 'test_2.o'into '.text._Z5name1v' in file 'test_1.o Function name1() is folded into name2() which is wrong. This happens because the addend is ignored and the wrong string "AAAAAA" is inlined. The attached patch fixes it. 2010-07-18 Sriraman Tallam <tmsriram@google.com> * gc.h (gc_process_relocs): Save the section header type for use by ICF. * icf.cc (get_section_contents): Get the addend from the text section for SHT_REL relocation sections. * icf.h (Icf::Sh_type_info): New typedef. (Icf::Reloc_info): Add new member sh_type_info. Is this ok to submit ? Thanks, -Sri.
Attachment:
icf_addend_sht_rel_bug.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |