Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Oct 2018 15:44:40 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 232291] ld.bfd (newer) and ld.lld (6 and imho 7) create empty sections when they should not
Message-ID:  <bug-232291-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D232291

            Bug ID: 232291
           Summary: ld.bfd (newer) and ld.lld (6 and imho 7) create empty
                    sections when they should not
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: bz@FreeBSD.org
                CC: arichardson@FreeBSD.org, dim@FreeBSD.org,
                    emaste@freebsd.org

Working on a possible solution for PR230857 it seemed that ld.bfd and ld.lld
are bug compatible.

The old version of ld.bfd currently in HEAD (GNU ld 2.17.50 [FreeBSD]
2007-07-03
, from before the branch of stable/12) seems to do the expected thing on
certain statements with regards to "Dot".

Newer versions of both ld.bfd (2.26) and ld.lld seem to fail to do the right
thing.

Strangely enough in old times that behaviour was not documented and worked,=
 for
newer version is documented and fails.


One of the possible solution for the above mentioned PR as initially outlin=
ed
in https://reviews.freebsd.org/D17512 was along the lines of the following
linker script snippet:

39 SECTIONS
40              {
41                      set_pcpu        :
42                      {
43                              *(set_pcpu)
44                              . =3D . + ABSOLUTE (___set_pcpu_pad) ;
45                      }
46              }

If ___set_pcpu_pad would be 0 the statement would be . =3D . + (sym=3D=3D0)=
  in which
case, was the section non-existent/empty before should not be created.  How=
ever
it is with lld and the above mentioned bfd version at least.

According to
https://sourceware.org/binutils/docs-2.31/ld/Output-Section-Discarding.html=
#Output-Section-Discarding
it should not be created:

QUOTE >>> Other link script directives that allocate space in an output sec=
tion
will also create the output section. So too will assignments to dot even if=
 the
assignment does not create space, except for =E2=80=98. =3D 0=E2=80=99, =E2=
=80=98. =3D . + 0=E2=80=99, =E2=80=98. =3D sym=E2=80=99,
=E2=80=98. =3D . + sym=E2=80=99 and =E2=80=98. =3D ALIGN (. !=3D 0, expr, 1=
)=E2=80=99 when =E2=80=98sym=E2=80=99 is an absolute
symbol of value 0 defined in the script. This allows you to force output of=
 an
empty section with =E2=80=98. =3D .=E2=80=99. <<<


We should make sure that the upstream linkers we use get fixed to properly =
work
as documented and as at least one seems to have in the past.   Having
bug-compatiility between the two is not helpful at all.


While they are broken we might have to end up splattering sections over all
kernel modules, adding BYTE(1)-kind padding to these sections and checking =
this
and filtering this out in the in-kernel linker, which is extra noise, extra
size, extra complexity, .. otherwise not needed, as well as possible proble=
ms
with out-of-tree compiled kernel modules.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-232291-227>