Skip to content

Commit

Permalink
utime,{,f,l}utimes{,at}: add 64 weak aliases
Browse files Browse the repository at this point in the history
__utime64()[1][2] is a weak alias in the musl world since 1.2.0.

__utime64() is implemented in the glibc world since 2.32[3]; and
__utimes64(), __lutimes64() and __futimesat64() are implemented in the
glibc world since 2.34[4][5][6]. They are all supported on legacy ABI
since 2.34[7].

Fixes:

	$ ido --multiarch --preserve-env=PERL_DL_NONLAZY --multiarch --preserve-env=PERL_DL_NONLAZY mmdebstrap --verbose --architectures=armhf --hook-dir=/usr/share/mmdebstrap/hooks/maybe-merged-usr trixie armhf-mobian-trixie-rootfs <support/mobian-trixie-sources.list
	_FORTIFY_SOURCE requires compiling with optimization (-O) at /usr/lib/perl5/5.38/vendor_perl/features.ph line 224.
	I: automatically chosen mode: root
	W: cannot mount because CAP_SYS_ADMIN is not in the effective set
	W: cannot execute mount
	I: armhf cannot be executed natively, but transparently using qemu-user binfmt emulation
	I: finding correct signed-by value...
	I: automatically chosen format: directory
	I: running --setup-hook directly: /usr/share/mmdebstrap/hooks/maybe-merged-usr/setup00.sh /home/gportay/src/iamroot/armhf-mobian-trixie-rootfs
	(...)
	I: installing essential packages...
	Selecting previously unselected package gcc-14-base:armhf.
	(Reading database ... 1 file or directory currently installed.)
	Preparing to unpack .../gcc-14-base_14-20240330-1_armhf.deb ...
	Unpacking gcc-14-base:armhf (14-20240330-1) ...
	dpkg: error processing archive /var/cache/apt/archives/gcc-14-base_14-20240330-1_armhf.deb (--install):
	 error setting timestamps of '/usr/share/doc/gcc-14-base/README.Debian.armhf.gz.dpkg-new': No such file or directory

See:

	# x86_64 (glibc)
	gportay@archlinux ~/src/iamroot $ readelf -s x86_64/libiamroot-linux-x86-64.so.2 | grep -E "utimes?64"
	(nothing)
	gportay@archlinux ~/src/iamroot $ readelf -s /usr/lib/libc.so.6 | grep -E "utimes?64"
	(nothing)

	# x86_64 (musl)
	gportay@archlinux ~/src/iamroot $ readelf -s x86_64/libiamroot-musl-x86_64.so.1 | grep -E "utimes?64"
	(nothing)
	gportay@archlinux ~/src/iamroot $ readelf -s /usr/lib/ld-musl-x86_64.so.1 | grep -E "utimes?64"
	(nothing)

	# i686 (glibc)
	gportay@archlinux ~/src/iamroot $ readelf -s i686/libiamroot-linux.so.2 | grep -E "utimes?64"
	   168: 00020fcc   117 FUNC    WEAK   DEFAULT    6 __lutimes64
	   250: 00029d00    81 FUNC    WEAK   DEFAULT    6 __utime64
	   332: 00029f2b   152 FUNC    WEAK   DEFAULT    6 __utimes64
	  1296: 00029f2b   152 FUNC    WEAK   DEFAULT    6 __utimes64
	  1339: 00029d00    81 FUNC    WEAK   DEFAULT    6 __utime64
	  1475: 00020fcc   117 FUNC    WEAK   DEFAULT    6 __lutimes64
	gportay@archlinux ~/src/iamroot $ readelf -s /usr/lib32/libc.so.6 | grep -E "utimes?64"
	  3036: 001156b0   117 FUNC    GLOBAL DEFAULT   12 __utime64@@GLIBC_2.34

	# i686 (musl)
	gportay@archlinux ~/src/iamroot $ readelf -s i686/libiamroot-musl-i386.so.1 | grep -E "utimes?64"
	   176: 00025dc3    98 FUNC    GLOBAL DEFAULT    7 __utime64
	  1231: 00025dc3    98 FUNC    GLOBAL DEFAULT    7 __utime64
	gportay@archlinux ~/src/iamroot $ readelf -s /usr/lib/ld-musl-i386.so.1 | grep -E "utimes?64"
	    70: 0005eb72   116 FUNC    GLOBAL DEFAULT   10 __utime64

	# aarch64 (glibc)
	gportay@archlinux ~/src/iamroot $ readelf -s aarch64/libiamroot-linux-aarch64.so.1 | grep -E "utimes?64"
	(nothing)
	gportay@archlinux ~/src/iamroot $ readelf -s /opt/aarch64-glibc-bleeding-edge/aarch64-buildroot-linux-gnu/sysroot/lib/libc.so.6 | grep -E "utimes?64"
	(nothing)

	# aarch64 (musl)
	gportay@archlinux ~/src/iamroot $ readelf -s aarch64/libiamroot-musl-aarch64.so.1 | grep -E "utimes?64"
	(nothing)
	gportay@archlinux ~/src/iamroot $ readelf -s /opt/aarch64-musl-bleeding-edge/aarch64-buildroot-linux-musl/sysroot/lib/ld-musl-aarch64.so.1 | grep -E "utimes?64"
	(nothing)

	# armhf (glibc)
	gportay@archlinux ~/src/iamroot $ readelf -s armhf/libiamroot-linux-armhf.so.3 | grep -E "utimes?64"
	   172: 00035060   240 FUNC    WEAK   DEFAULT    7 __lutimes64
	   254: 00046818   204 FUNC    WEAK   DEFAULT    7 __utime64
	   336: 00046cd0   400 FUNC    WEAK   DEFAULT    7 __utimes64
	  2631: 00046cd0   400 FUNC    WEAK   DEFAULT    7 __utimes64
	  2674: 00046818   204 FUNC    WEAK   DEFAULT    7 __utime64
	  2810: 00035060   240 FUNC    WEAK   DEFAULT    7 __lutimes64
	gportay@archlinux ~/src/iamroot $ readelf -s /opt/armv7-eabihf-glibc-bleeding-edge/arm-buildroot-linux-gnueabihf/sysroot/lib/libc.so.6 | grep -E "utimes?64"
	   829: 000cad8c    72 FUNC    GLOBAL DEFAULT   12 __utime64@@GLIBC_2.34
	 10050: 000cad8c    72 FUNC    LOCAL  DEFAULT   12 __GI___utime64
	 12077: 000cd958    84 FUNC    LOCAL  DEFAULT   12 __GI___futimes64
	 12225: 000d2fec    88 FUNC    LOCAL  DEFAULT   12 __GI___utimes64
	 12328: 000cf2d0    88 FUNC    LOCAL  DEFAULT   12 __GI___lutimes64
	 13486: 000cd958    84 FUNC    GLOBAL DEFAULT   12 __futimes64
	 14272: 000cf2d0    88 FUNC    GLOBAL DEFAULT   12 __lutimes64
	 14925: 000d2fec    88 FUNC    GLOBAL DEFAULT   12 __utimes64
	 15290: 000cad8c    72 FUNC    GLOBAL DEFAULT   12 __utime64

	# armhf (musl)
	gportay@archlinux ~/src/iamroot $ readelf -s armhf/libiamroot-musl-armhf.so.1 | grep -E "utimes?64"
	   182: 0003f33c   200 FUNC    GLOBAL DEFAULT    7 __utime64
	  2447: 0003f33c   200 FUNC    GLOBAL DEFAULT    7 __utime64
	gportay@archlinux ~/src/iamroot $ readelf -s /opt/armv7-eabihf-musl-bleeding-edge/arm-buildroot-linux-musleabihf/sysroot/lib/ld-musl-armhf.so.1 | grep -E "utimes?64"
	    74: 0006086c   164 FUNC    GLOBAL DEFAULT    8 __utime64
	  6995: 0006086c   164 FUNC    GLOBAL DEFAULT    8 __utime64

[1]: https://git.musl-libc.org/cgit/musl/tree/include/utime.h?h=v1.2.5#n22
[2]: https://git.musl-libc.org/cgit/musl/commit/include/utime.h?id=1febd21d3fb7b78f6fc13e48b3ff2a396a607a15
[3]: https://sourceware.org/git/?p=glibc.git;a=commit;h=66449d93393dabbfcf33c045c1d3cb49e77a25e4
[4]: https://sourceware.org/git/?p=glibc.git;a=commit;h=d962a5d68a140811eb4b6cf788c41ff471fd95b4
[5]: https://sourceware.org/git/?p=glibc.git;a=commit;h=1a5e12826c02bce330be3f3592c5405314495d66
[6]: https://sourceware.org/git/?p=glibc.git;a=commit;h=8b8f39376be81dc09560d23dbec59cd7080d54f6
[7]: https://sourceware.org/git/?p=glibc.git;a=commit;h=47f24c21ee38701ae275aa9e451f70fa3e77478c
  • Loading branch information
gportay committed May 10, 2024
1 parent d6b894a commit 2167a8f
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Set the `DT_RUNPATH` of `ld-iamroot.so(8)` to the iamroot library directory
- Add the `ld-iamroot.so(8)` option `--origin` to set the iamroot library
directory
- Create the `64` weak aliases `__futimesat64()`, `__lutimes64()`,
`__utime64()` and `__utimes64()`

### Changed

Expand Down
12 changes: 11 additions & 1 deletion futimesat.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Gaël PORTAY
* Copyright 2021-2024 Gaël PORTAY
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
Expand Down Expand Up @@ -44,3 +44,13 @@ int futimesat(int dfd, const char *path, const struct timeval times[2])

return __futimesat(dfd, path, times);
}

#ifdef __GLIBC__
#if __TIMESIZE == 32
#ifdef _LARGEFILE64_SOURCE
int __futimesat64 (int __fd, const char *__file,
const struct timeval __tvp[2]) __THROW;
weak_alias(futimesat, __futimesat64);
#endif
#endif
#endif
19 changes: 18 additions & 1 deletion lutimes.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/*
* Copyright 2021-2022 Gaël PORTAY
* Copyright 2021-2022,2024 Gaël PORTAY
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/

#include <stdio.h>
#include <errno.h>

#include <utime.h>

#include "iamroot.h"

/*
* Stolen from musl (src/legacy/lutimes.c)
*
Expand All @@ -27,3 +34,13 @@ int lutimes(const char *filename, const struct timeval tv[2])
}
return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW);
}

#ifdef __GLIBC__
#if __TIMESIZE == 32
#ifdef _LARGEFILE64_SOURCE
int __lutimes64 (const char *__file, const struct timeval __tvp[2])
__THROW __nonnull ((1));
weak_alias(lutimes, __lutimes64);
#endif
#endif
#endif
20 changes: 19 additions & 1 deletion utime.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/*
* Copyright 2021-2022 Gaël PORTAY
* Copyright 2021-2022,2024 Gaël PORTAY
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/

#include <stdio.h>
#include <errno.h>

#include <utime.h>

#include "iamroot.h"

/*
* Stolen from musl (src/time/utime.c)
*
Expand All @@ -23,3 +30,14 @@ int utime(const char *path, const struct utimbuf *times)
{ .tv_sec = times->actime }, { .tv_sec = times->modtime }})
: 0, 0);
}

#ifdef __GLIBC__
#if __TIMESIZE == 32
#ifdef _LARGEFILE64_SOURCE
int __utime64 (const char *__file,
const struct utimbuf *__file_times)
__THROW __nonnull ((1));
weak_alias(utime, __utime64);
#endif
#endif
#endif
10 changes: 10 additions & 0 deletions utimes.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ int utimes(const char *path, const struct timeval times[2])

return ret;
}

#ifdef __GLIBC__
#if __TIMESIZE == 32
#ifdef _LARGEFILE64_SOURCE
int __utimes64 (const char *__file, const struct timeval __tvp[2])
__THROW __nonnull ((1));
weak_alias(utimes, __utimes64);
#endif
#endif
#endif

0 comments on commit 2167a8f

Please sign in to comment.