Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2020 02:39:54 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 245179] lld: wrong/misleading "SHF_MERGE section size must be a multiple of sh_entsize"
Message-ID:  <bug-245179-227@https.bugs.freebsd.org/bugzilla/>

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

            Bug ID: 245179
           Summary: lld: wrong/misleading "SHF_MERGE section size must be
                    a multiple of sh_entsize"
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: andrew@tao11.riddles.org.uk
                CC: dim@FreeBSD.org, emaste@freebsd.org,
                    kevans@freebsd.org
             Flags: mfc-stable12?, mfc-stable11?

In function ObjFile<ELFT>::shouldMerge in lld/ELF/InputFiles.cpp:

  if (sec.sh_size % entSize)
    fatal(toString(this) +
          ": SHF_MERGE section size must be a multiple of sh_entsize");

  uint64_t flags =3D sec.sh_flags;
  if (!(flags & SHF_MERGE))
    return false;

Notice that the size is checked _before_ looking at whether SHF_MERGE is se=
t.
This means that the error is produced for sections that do not have SHF_MER=
GE
set at all, which is either misleading or wrong.

Judging by the report in #219717 where this was found, the BFD linker did n=
ot
care about sh_entsize of non-mergeable sections. If this check is only need=
ed
for mergeable sections, then surely it should be made _after_ SHF_MERGE is
checked for.

Since this check is skipped when -Wl,-O0 is in effect, I do not believe it =
is
actually necessary to check that size is a multiple of sh_entsize when not
merging sections. If I'm wrong about that, though, then the check would nee=
d to
be both moved to somewhere else and changed to not mention SHF_MERGE in the
error message.

--=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-245179-227>