This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] RISC-V: Optimize lui and auipc relaxations for undefweak symbols
- From: Nelson Chu <nelson dot chu at sifive dot com>
- To: Jim Wilson <jimw at sifive dot com>
- Cc: Binutils <binutils at sourceware dot org>, Yi-Hsiu Hsu <yihsiu dot hsu at sifive dot com>, Kito Cheng <kito dot cheng at sifive dot com>
- Date: Mon, 23 Sep 2019 09:21:27 +0800
- Subject: Re: [PATCH] RISC-V: Optimize lui and auipc relaxations for undefweak symbols
- References: <CAJYME4HUU5vE=9R1xKUTTTFWehmMZVvxqzCzd74FWEs+vko1Jg@mail.gmail.com> <CAFyWVabpegD6j3FAV4nsi8HbUFkTVSY0pYDMx4LiHbE2p2uFsQ@mail.gmail.com> <CAJYME4GA__ntEfSOKTdRp2bp=zko0-43eZWQerqO3AWLNv8XMQ@mail.gmail.com> <CAFyWVaYvq5Y0MCkfz5B6Hy+ntrP23+cx-Ue7QTOzEHhcBUgpqw@mail.gmail.com> <CAJYME4HfAutLYoxzZ+=XTeJya8BL35Tm-xBC4_WRJk3XHtT8=A@mail.gmail.com> <CAFyWVaaJ351LFZPm1=4Vu5hnfG0i+m=RTN8GXyum8ZGDHHHjBw@mail.gmail.com>
Dear Jim,
> When doing some last minute testing, I got some LTO errors that were
> difficult to reproduce. The problem turns out to be the part of the
> patch that does
> - else if (h->root.u.def.section->output_section == NULL
> - || (h->root.type != bfd_link_hash_defined
> - && h->root.type != bfd_link_hash_defweak))
> + else if (!undefined_weak
> + && (h->root.u.def.section->output_section == NULL
> + || (h->root.type != bfd_link_hash_defined
> + && h->root.type != bfd_link_hash_defweak)))
> This causes us to fall through to code that does
> sym_sec = h->root.u.def.section
> but this isn't valid for an undefined variable. def.section happens
> to overlap undef.abfd, and we end up with a abfd pointer instead of a
> section pointer, which can cause a crash we end up with the wrong
> garbage values there. Usually it works, sometimes it crashes. I
> changed the code to add an explicit else if for undefined_weak to set
> symval and sym_sec to reasonable values.
>
> I committed the patch with my change, which is attached below.
Thanks so much! This modified patch is more reasonable.
I am grateful for your help :)
> I also rewrote the ChangeLog entries. They are supposed to describe
> the textual changes you are making. I'm old school; I prefer
> ChangeLog entries written like the ones I checked in.
OK I will pay special attention to this in the future :)