This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Patch for ICF string inline bug for SHT_REL sections.
- From: =?big5?b?RG91ZyBLd2FuICjD9q62vHcp?= <dougkwan at google dot com>
- To: Sriraman Tallam <tmsriram at google dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, Cary Coutant <ccoutant at google dot com>, binutils <binutils at sourceware dot org>
- Date: Sun, 18 Jul 2010 23:12:12 -0700
- Subject: Re: Patch for ICF string inline bug for SHT_REL sections.
- References: <AANLkTikkvAOUuyOTGMG7SgogBmRkRifB0qB6Lwryl9lp@mail.gmail.com>
That affects all targets, including ARM, I guess?
-Doug
在 2010年7月18日下午5:43,Sriraman Tallam <tmsriram@google.com> 寫道:
> 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.
>