https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69357

            Bug ID: 69357
           Summary: libgo refers to _end in a non-weak way
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: go
          Assignee: ian at airs dot com
          Reporter: rguenth at gcc dot gnu.org
                CC: cmang at google dot com
  Target Milestone: ---

bfd has

              /* A symbol from a library loaded via DT_NEEDED of some
                 other library is referenced by a regular object.
                 Add a DT_NEEDED entry for it.  Issue an error if
                 --no-add-needed is used and the reference was not
                 a weak one.  */
              if (old_bfd != NULL
                  && (elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
                {
                  (*_bfd_error_handler)
                    (_("%B: undefined reference to symbol '%s'"),
                     old_bfd, name);
                  bfd_set_error (bfd_error_missing_dso);
                  goto error_free_vers;
                }

and with -static-libgo you get a reference to _end from malloc.o from
runtime/malloc.goc:

void
runtime_mallocinit(void)
{
        byte *p, *p1;
        uintptr arena_size, bitmap_size, spans_size, p_size;
        extern byte _end[];

which uses a non-weak reference to this "magic" symbol marking the end of the
BSS section.

Unfortunately all shlibs provide this symbol as well so if you do

gccgo-5 <prg> -lsomelib -static-libgo

the you get sth like the following from ld:

libgo.a(malloc.o): undefined reference to symbol '_end'
libselinux.so: error adding symbols: DSO missing from command line

bfd source suggests to make the _end reference in libgo weak.

Reply via email to