• efficient way to detect linker script files?

    From Serafeim (Serafi) Zanikolas@21:1/5 to All on Tue Oct 22 23:10:02 2024
    --b5e6a6cc3c88c057f20f81cf4a40ab5ff20b1a8b7795bf4426ce596fc890 Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain; charset=UTF-8

    hi,

    I'd like to discover all installed linker scripts, for the purposes of #823531 (check for broken linker scripts files). it's not clear to me that there's a convention I could rely on to avoid brute forcing filetype detection of everything under /lib/${DEB_HOST_GNU_TYPE} (that'd be /lib/x86_64-linux-gnu in my system).

    my intuition would be to only look in /lib/${DEB_HOST_GNU_TYPE}/ldscripts, and ignore *.so named files, but a few linker scripts break both of those assumptions:

    /lib/x86_64-linux-gnu/libc.so
    /lib/x86_64-linux-gnu/libm.a
    /lib/x86_64-linux-gnu/libusb.so

    are these misplaced and misnamed? I didn't find any relevant guidance skimming through policy.

    thanks,
    serafi

    --b5e6a6cc3c88c057f20f81cf4a40ab5ff20b1a8b7795bf4426ce596fc890
    Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCAAdFiEEA2RWqo7IwLCLSFYbT59tVQ7WEioFAmcYEm0ACgkQT59tVQ7W Eiq/mg/9GyGbYWTfYYmD78DMb86W2ooCdlW+sgcpBvFJAr9Wqw/gKK/SZ09fNAQR qihwMSML7kHefFuNAJlD7N8xigrz7FpuvbDYpbY5sh6HjbFfS5alEYVyer8BUWPf NgaJ+eSC6NA4alkYT7v31lcM2DLtcFgyWSa8NAr5pwClqey16JiTLGr/XMhzwisx lz0rg7Vr/Jq9qQ+gK/2RlgpF724o6uyq71NW6VdFDmORtZtHe74qU/I+lXk+I7Qc MDsrQ+ci95SwY8JwTlIaos2YykQNftQ9+s+WupvCTXNBcJrJnI71T+vbmIkwHkm6 ODnGNIc4Qo+WirSvaO/HyXHEJOhlhh0DnTjhsPpm3tuHjEXXugkG9feNT1Avadd0 Pd4BbqTU/8c5qLmy+lgsOrvS/W0L2MCyaDIWuSnqCdWuEajM1f7JUDtVp3VItofX ClM2DuKfcpqqKJvug6MYJfK74jzD+/ShMUAIO/hNMXk6HEEZDYiwpeSnsjKiHuzh tGx54gxlQSXQGim+sFaFBhE/5kaQ3oBBFPLYiRmPFz2zz0evfkiuDmnT1IZAqO0H CSd3FLw2QmnBw5Nfp3jO/ulanufkLGMKe7d2+pZvkllhXbgvFrsblU8AjC4p1Yoa foR/VVZcG+Zm9U2Xji4RHcsY58djKxZ2VhQZRVcNFCivozX7fNQ)z8
    -----END PGP SIGNATURE-----

    --b5e6a6cc3c88c057f20f81cf4a40ab5ff20b1a8b7795bf4426ce596fc890--

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to All on Wed Oct 23 01:50:01 2024
    Hi!

    On Tue, 2024-10-22 at 23:00:29 +0200, Serafeim (Serafi) Zanikolas wrote:
    I'd like to discover all installed linker scripts, for the purposes of #823531 (check for broken linker scripts files). it's not clear to me
    that there's a convention I could rely on to avoid brute forcing
    filetype detection of everything under /lib/${DEB_HOST_GNU_TYPE}
    (that'd be /lib/x86_64-linux-gnu in my system).

    The current convention is to have "GNU ld script" on the first line,
    by way of ldconfig(8) otherwise complaining about an unknown file format.

    Perhaps if you want to avoid having to open all the files, then a
    heuristic could be to discard files bigger than some threshold. Linker
    scripts should in general not be that big.

    my intuition would be to only look in /lib/${DEB_HOST_GNU_TYPE}/ldscripts, and ignore *.so named files, but a few linker scripts break both of those assumptions:

    I think checking for stuff under /ldscripts/ might also be good, but I
    assume the bug report you mention was precisely concerned about *.so or
    *.a linker scripts under /usr/lib. These are needed when you want to transparently move functions around or provide them in different
    libraries but not require users to specify different libraries to link
    to, while not breaking compilation.

    /lib/x86_64-linux-gnu/libc.so
    /lib/x86_64-linux-gnu/libm.a
    /lib/x86_64-linux-gnu/libusb.so

    Another one I'm aware of would be libbsd.so, where it was added to transparently redirect code linking against it that used MD5 functions
    into linking against libmd.so when needed. Instead of requiring a
    SOVERSION bump.

    are these misplaced and misnamed? I didn't find any relevant guidance skimming through policy.

    These are fine, but perhaps not very common. I don't think the Debian
    policy has anything about it, I guess because of the above.

    Thanks,
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Serafeim (Serafi) Zanikolas@21:1/5 to All on Wed Oct 23 21:50:01 2024
    --2343639944d3c5df7ca9b5faff9d6413cc17a473a96852b1d335c7e0adfa Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain; charset=UTF-8

    hola Guillem,

    thanks so much for such a thorough response :)

    to summarize, I'll look for:

    - files matching /lib/${DEB_HOST_GNU_TYPE}/*.{a,so} that are below a certain
    size and contain "GNU ld script" in the first line (if they're text files)
    - all files under /lib/${DEB_HOST_GNU_TYPE}/ldscripts

    moltissimes grĂ cies,
    serafi

    --2343639944d3c5df7ca9b5faff9d6413cc17a473a96852b1d335c7e0adfa
    Content-Type: application/pgp-signature; name="signature.asc"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCAAdFiEEA2RWqo7IwLCLSFYbT59tVQ7WEioFAmcZUOkACgkQT59tVQ7W Eir9JA/6A2S5lSYEHmlHF3bfVVQ99tXarXBXwaBGvXp5uAOAqm65HDYvghXBQUzO ObHsTWKMDhOTKeyC7S3Ush63TiudWt+KfFu1mxpiM3JQpn+LZDWTrAiOb739qqyZ /VgeMCWWp/BoPfiLeq7AZ9Dyc7WHapc67fSkGOaQNSdpOFp5PpvsN6EvZ5wRsNpG SGIT5p35BrOryJGKeShGeL6pgunJRTr/pfO2kl8u8KptWQp/amB9b1FbzgHwwhSL ckkxVreW9a+8O22UZS3quhKHuwXOuFwNlz/fpA8gR6l24DEFr3z8SsAY78TPwAvE GBthaFxOfcuG/90wSUkAKLfSzboLYo/a+vK3AsEka5L8Yg7pI56VHUD9Jaem3Aa4 6MyjH16QtFrGGLU2G8mBiWtnmknMMMupw9pqw2yH78xtvyc3noIGd9jXYVImueGz XWq7OiR8DTaTgToY3imMej+n3dkETaSjQmVTPFCHjS3aQ+1bH2OyBJvEvxiqVwG8 9Eb6/WvGVRxFELx2cXz1BcOvBop/A7PDsSNNIIvZ5cR2X0WbpE92cxVo2LCOYRIX NMi4wroy2JWrZbCP23LNgSEG74jMgON4Oij31k1LK4mR3CJIZV+y+gkyYwHeZghU ES2wfaa5T4ELUYg/UNBMAsBZhLL4i7TOh+fTBjKXLea2J2HvMiU=ZvJj
    -----END PGP SIGNATURE-----

    --2343639944d3c5df7ca9b5faff9d6413cc17a473a96852b1d335c7e0adfa--

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)