This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] PR ld/21903: Treat common symbol as undefined for --no-define-common
On Sun, Aug 06, 2017 at 07:53:33AM -0700, H.J. Lu wrote:
> On Fri, Aug 4, 2017 at 5:22 AM, H.J. Lu <firstname.lastname@example.org> wrote:
> > When --no-define-common is used to build shared library, treat common
> > symbol as undefined so that common symbols that are referenced from a
> > shared library to be assigned addresses only in the main program. This
> > eliminates the unused duplicate space in the shared library, and also
> > prevents any possible confusion over resolving to the wrong duplicate
> > when there are many dynamic modules with specialized search paths for
> > runtime symbol resolution.
> > --no-define-common is only allowed when building a shared library.
> > OK for master?
> I am going to check it in.
Why the hurry?
> > --- a/bfd/elflink.c
> > +++ b/bfd/elflink.c
> > @@ -4250,6 +4250,11 @@ error_free_dyn:
> > override = FALSE;
> > + /* Treat common symbol as undefined for --no-define-common. */
> > + if (isym->st_shndx == SHN_COMMON
> > + && info->inhibit_common_definition)
> > + isym->st_shndx = SHN_UNDEF;
> > +
> > flags = BSF_NO_FLAGS;
> > sec = NULL;
> > value = isym->st_value;
Surely this should be put a little later.
common = bed->common_definition (isym);
if (common && info->inhibit_common_definition)
isym->st_shndx = SHN_UNDEF;
common = FALSE;
The testcase wasn't checked very well either. It fails on arc, cris,
and frv. Why do you need _start and main, and wouldn't it be better
to put the ".dc.a foo" in .data?
Australia Development Lab, IBM