Page MenuHomeFreeBSD

csu: Fix dynamiclib/init_test:jcr_test on !HAVE_CTORS archs
ClosedPublic

Authored by kevans on Wed, Oct 23, 6:59 PM.

Details

Summary

.jcr still needs a 0-entry added in crtend, even on !HAVE_CTORS archs. Without it, .jcr section, when no data is present here, overlaps with next section and register_classes in crtbegin will be examining the wrong item.

PR: 241439

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kevans created this revision.Wed, Oct 23, 6:59 PM
kevans retitled this revision from Fix dynamclib/init_test:jcr_test on !HAVE_CTORS archs to csu: Fix dynamiclib/init_test:jcr_test on !HAVE_CTORS archs.Wed, Oct 23, 7:12 PM
andrew accepted this revision.Fri, Oct 25, 2:09 PM

Do you know where the .jcr section is coming from? I don't see it on arm64.

This revision is now accepted and ready to land.Fri, Oct 25, 2:09 PM

Do you know where the .jcr section is coming from? I don't see it on arm64.

Hmm... so I downloaded FreeBSD-13.0-CURRENT-arm64-aarch64-PINE64-20191018-r353709.img to investigate, and that one seems to have them as well.

armv7 (FreeBSD-13.0-CURRENT-arm-armv7-GENERICSD-20191018-r353709.img):

$ readelf -a /mnt/usr/lib/debug/bin/ls.debug | grep -Ei '__jcr|\.jcr'
  [17] .jcr              NOBITS          00019000 0000a0 000000 00  WA  0   0  4
    20: 0000000000019000     0 OBJECT  LOCAL  DEFAULT   17 __JCR_LIST__

arm64 (FreeBSD-13.0-CURRENT-arm64-aarch64-PINE64-20191018-r353709.img):

$ readelf -a /mnt2/usr/lib/debug/bin/ls.debug | grep -Ei '__jcr|\.jcr' -A1
  [16] .jcr              NOBITS           0000000000220000  00000090
       0000000000000000  0000000000000000  WA       0     0     8
--
    44: 0000000000220000     0 OBJECT  LOCAL  DEFAULT   16 __JCR_LIST__
    45: 0000000000210234    52 FUNC    LOCAL  DEFAULT   12 register_classes

(I had to -A1 it so the size was included, and the section at least still exists in /bin/ls)

Given this, I suspect the __JCR_LIST__ reference in crtbegin is creating the 0-sized section. I would think maybe a difference from clang 8 -> 9 since base only moved forward not that long ago, but perhaps you've upgraded beyond that already.

This revision was automatically updated to reflect the committed changes.