Message ID | 1422535407-4597-1-git-send-email-will.newton@linaro.org |
---|---|
State | New |
Headers | show |
On 29 January 2015 at 12:43, Will Newton <will.newton@linaro.org> wrote: > Unless pointer_equality_needed is set then set st_value to be zero > for undefined symbols. This relates to BZ #16715. > > bfd/ChangeLog: > > 2015-01-28 Will Newton <will.newton@linaro.org> > > * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): > Set st_value to zero for undefined symbols unless > pointer_equality_needed. > --- > bfd/elfnn-aarch64.c | 6 ++++++ > 1 file changed, 6 insertions(+) Ping? > diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c > index 37de7fa..ee718c5 100644 > --- a/bfd/elfnn-aarch64.c > +++ b/bfd/elfnn-aarch64.c > @@ -7441,6 +7441,12 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, > comparisons work between an application and shared > library. */ > sym->st_shndx = SHN_UNDEF; > + /* If the symbol is weak, we do need to clear the value. > + Otherwise, the PLT entry would provide a definition for > + the symbol even if the symbol wasn't defined anywhere, > + and so the symbol would never be NULL. */ > + if (!h->ref_regular_nonweak || !h->pointer_equality_needed) > + sym->st_value = 0; > } > } > > -- > 2.1.0 >
On 3 February 2015 at 12:28, Alan Modra <amodra@gmail.com> wrote: > On Tue, Feb 03, 2015 at 10:36:27AM +0000, Will Newton wrote: >> On 29 January 2015 at 12:43, Will Newton <will.newton@linaro.org> wrote: >> > Unless pointer_equality_needed is set then set st_value to be zero >> > for undefined symbols. This relates to BZ #16715. >> > >> > bfd/ChangeLog: >> > >> > 2015-01-28 Will Newton <will.newton@linaro.org> >> > >> > * elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): >> > Set st_value to zero for undefined symbols unless >> > pointer_equality_needed. >> > --- >> > bfd/elfnn-aarch64.c | 6 ++++++ >> > 1 file changed, 6 insertions(+) >> >> Ping? >> >> > diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c >> > index 37de7fa..ee718c5 100644 >> > --- a/bfd/elfnn-aarch64.c >> > +++ b/bfd/elfnn-aarch64.c >> > @@ -7441,6 +7441,12 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, >> > comparisons work between an application and shared >> > library. */ >> > sym->st_shndx = SHN_UNDEF; >> > + /* If the symbol is weak, we do need to clear the value. >> > + Otherwise, the PLT entry would provide a definition for >> > + the symbol even if the symbol wasn't defined anywhere, >> > + and so the symbol would never be NULL. */ >> > + if (!h->ref_regular_nonweak || !h->pointer_equality_needed) >> > + sym->st_value = 0; >> > } >> > } > > Your description of the patch, changelog, and the new comment and the > one above it doesn't quite match up with what the code is doing. The > code is fine, but please fix the comment and changelog. Yes, I wondered whether to change the comment or not. i copied the code from the ARM port (which I was the last to modify so it's not like I can disclaim any responsibility for that!) which is where the comment came from too. I'll fix the comment in both places.
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 37de7fa..ee718c5 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -7441,6 +7441,12 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, comparisons work between an application and shared library. */ sym->st_shndx = SHN_UNDEF; + /* If the symbol is weak, we do need to clear the value. + Otherwise, the PLT entry would provide a definition for + the symbol even if the symbol wasn't defined anywhere, + and so the symbol would never be NULL. */ + if (!h->ref_regular_nonweak || !h->pointer_equality_needed) + sym->st_value = 0; } }