Louis-Philippe Véronneau pushed to branch master at lintian / lintian


Commits:
ccdac289 by Nilesh Patra at 2026-08-03T18:59:08+02:00
Check for `__fentry__` for profiling options as well

gcc-16 seems to use `__fentry__` instead of mcount for at least x86 where the
tests for lintian are run. As per release notes of gcc-16

https://gcc.gnu.org/gcc-16/changes.html

It says:

| The new --enable-x86-64-mfentry configure option enables `-mfentry` which 
uses `__fentry__`,
| instead of mcount for profiling on x86-64. This option is enabled by default 
for glibc targets.

Hence, it appears that this is effectively compiled with `-pg -mfentry` instead 
of only `-pg` which
will enable `mcount`. Lintian should also check for `__fentry__` to detect 
profiling.

- - - - -
5abd3f7f by Nilesh Patra at 2026-08-03T22:49:01+02:00
tests(binaries-general): Also add a test to compile with `-mno-fentry` on amd64 
to continue testing against `mcount`

$ readelf -Ws basic | grep fentry
     8: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND 
__fentry__@GLIBC_2.13 (6)
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __fentry__@GLIBC_2.13

$ readelf -Ws basic.nofentry | grep mcount
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mcount@GLIBC_2.2.5 
(3)
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mcount@GLIBC_2.2.5

- - - - -


4 changed files:

- lib/Lintian/Check/Binaries/Profiling.pm
- t/recipes/checks/binaries/profiling/binaries-general/build-spec/debian/rules
- t/recipes/checks/binaries/profiling/binaries-general/build-spec/orig/Makefile
- t/recipes/checks/binaries/profiling/binaries-general/eval/hints


Changes:

=====================================
lib/Lintian/Check/Binaries/Profiling.pm
=====================================
@@ -41,9 +41,11 @@ sub visit_installed_files {
 
     for my $symbol (@{$item->elf->{SYMBOLS} // [] }) {
 
-        # According to the binutils documentation[1], the profiling symbol
-        # can be named "mcount", "_mcount" or even "__mcount".
-        # [1] http://sourceware.org/binutils/docs/gprof/Implementation.html
+        $is_profiled = 1
+          if $symbol->version =~ /^GLIBC_.*/
+          && $symbol->name =~ m{\A __fentry__ \Z}xsm
+          && ($symbol->section eq 'UND' || $symbol->section eq '.text');
+
         $is_profiled = 1
           if $symbol->version =~ /^GLIBC_.*/
           && $symbol->name =~ m{\A _?+ _?+ (gnu_)?+mcount(_nc)?+ \Z}xsm


=====================================
t/recipes/checks/binaries/profiling/binaries-general/build-spec/debian/rules
=====================================
@@ -1,6 +1,9 @@
 #!/usr/bin/make -f
 
 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
+ifeq ($(DEB_HOST_ARCH), amd64)
+export NO_FENTRY := -mno-fentry
+endif
 
 %:
        dh $@


=====================================
t/recipes/checks/binaries/profiling/binaries-general/build-spec/orig/Makefile
=====================================
@@ -16,6 +16,7 @@ all:
        # rpath not matching any of the exceptions to the rpath checks
        #  - with profiling enabled.
        $(COMPILE_NOPIE) -o basic basic.c -pg -Wl,--rpath,/usr/local/lib
+       $(COMPILE_NOPIE) -o basic.nofentry basic.c -pg $(NO_FENTRY) 
-Wl,--rpath,/usr/local/lib
        # rpath shipped in the package, but one of {/usr}?/lib
        $(COMPILE) -o basiclibrpath basic.c -Wl,--rpath,/usr/lib
        # non-special rpath shipped in the package
@@ -37,6 +38,7 @@ install:
        install -d $(DESTDIR)/usr/bin
 
        install -m 755 -c basic $(DESTDIR)/usr/share/foo/basic
+       install -m 755 -c basic.nofentry $(DESTDIR)/usr/share/foo/basic.nofentry
        objcopy --only-keep-debug basic 
$(DESTDIR)/usr/lib/debug/usr/share/foo/basic
        strip -s $(DESTDIR)/usr/lib/debug/usr/share/foo/basic
        install -m 755 -c basiclibrpath $(DESTDIR)/usr/lib/foo/basiclibrpath
@@ -59,6 +61,6 @@ install:
        install -m 755 basic.static $(DESTDIR)/usr/bin/static
 
 clean distclean:
-       rm -f basic
+       rm -f basic basic.nofentry
 
 check test:


=====================================
t/recipes/checks/binaries/profiling/binaries-general/eval/hints
=====================================
@@ -1 +1,2 @@
 binaries-general (binary): binary-compiled-with-profiling-enabled 
[usr/share/foo/basic]
+binaries-general (binary): binary-compiled-with-profiling-enabled 
[usr/share/foo/basic.nofentry]



View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/compare/79d58704c8d5b744a8c5ea6080a312f70a129c20...5abd3f7f230ba0ebe96e513eab7c477f6e4c1d84

-- 
View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/compare/79d58704c8d5b744a8c5ea6080a312f70a129c20...5abd3f7f230ba0ebe96e513eab7c477f6e4c1d84
You're receiving this email because of your account on salsa.debian.org. Manage 
all notifications: https://salsa.debian.org/-/profile/notifications | Help: 
https://salsa.debian.org/help


Reply via email to