From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id B0548382E82F; Thu, 4 Mar 2021 11:33:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0548382E82F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/y2038] elf: Use LFS and 64 bit time_t for installed programs X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/y2038 X-Git-Oldrev: ae894554d5942e9e7c7d716b604ea849ac74647d X-Git-Newrev: 8fddb5d41809cee0e2988e4d122cb24f2fb46149 Message-Id: <20210304113310.B0548382E82F@sourceware.org> Date: Thu, 4 Mar 2021 11:33:10 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Mar 2021 11:33:10 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8fddb5d41809cee0e2988e4d122cb24f2fb46149 commit 8fddb5d41809cee0e2988e4d122cb24f2fb46149 Author: Adhemerval Zanella Date: Tue Mar 2 17:09:40 2021 -0300 elf: Use LFS and 64 bit time_t for installed programs The patch enables for pldd, sprof, ldconfig, and sln. It replaces the usage of the symbol64 GLIBC extension for the generic name, since 64 bit time_t is only support for _FILE_OFFSET_BITS=64 and not for _LARGEFILE64_SOURCE. Diff: --- elf/Makefile | 13 ++++++++++- elf/chroot_canon.c | 4 ++-- elf/ldconfig.c | 58 +++++++++++++++++++++++----------------------- elf/readlib.c | 6 ++--- elf/sln.c | 4 ++-- elf/sprof.c | 4 ++-- sysdeps/generic/ldconfig.h | 6 ++--- 7 files changed, 53 insertions(+), 42 deletions(-) diff --git a/elf/Makefile b/elf/Makefile index b06bf6ca20..bad8594e64 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -79,6 +79,8 @@ ifeq (yes,$(have-loop-to-function)) CFLAGS-rtld.c += -fno-tree-loop-distribute-patterns endif +CFLAGS-pldd.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 + # Compile rtld itself without stack protection. # Also compile all routines in the static library that are elided from # the shared libc because they are in libc.a in the same way. @@ -663,14 +665,23 @@ $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \ mv -f $@.new $@ $(objpfx)sprof: $(libdl) +CFLAGS-sprof.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 $(objpfx)sln: $(sln-modules:%=$(objpfx)%.o) +CFLAGS-sln.c += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 $(objpfx)ldconfig: $(ldconfig-modules:%=$(objpfx)%.o) +include $(o-iterator) +define o-iterator-doit +$(foreach f,$(ldconfig-modules),$(objpfx)$(f)$(o)): CFLAGS += -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 +endef +object-suffixes-left := $(all-object-suffixes) +include $(o-iterator) SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"' CFLAGS-ldconfig.c += $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \ - -D'SLIBDIR="$(slibdir)"' + -D'SLIBDIR="$(slibdir)"' \ + -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 libof-ldconfig = ldconfig CFLAGS-dl-cache.c += $(SYSCONF-FLAGS) CFLAGS-cache.c += $(SYSCONF-FLAGS) diff --git a/elf/chroot_canon.c b/elf/chroot_canon.c index 045611e730..a70fd25046 100644 --- a/elf/chroot_canon.c +++ b/elf/chroot_canon.c @@ -67,7 +67,7 @@ chroot_canon (const char *chroot, const char *name) for (start = end = name; *start; start = end) { - struct stat64 st; + struct stat st; /* Skip sequence of multiple path-separators. */ while (*start == '/') @@ -114,7 +114,7 @@ chroot_canon (const char *chroot, const char *name) dest = mempcpy (dest, start, end - start); *dest = '\0'; - if (lstat64 (rpath, &st) < 0) + if (lstat (rpath, &st) < 0) { if (*end == '\0') goto done; diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 28ed637a29..5a9e9318cc 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -83,7 +83,7 @@ struct dir_entry { char *path; int flag; - ino64_t ino; + ino_t ino; dev_t dev; const char *from_file; int from_line; @@ -337,7 +337,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ inode data from *ST. */ static struct dir_entry * new_sub_entry (const struct dir_entry *entry, const char *path, - const struct stat64 *st) + const struct stat *st) { struct dir_entry *new_entry = xmalloc (sizeof (struct dir_entry)); new_entry->from_file = entry->from_file; @@ -409,7 +409,7 @@ add_glibc_hwcaps_subdirectories (struct dir_entry *entry, const char *path) while (true) { errno = 0; - struct dirent64 *e = readdir64 (dir); + struct dirent *e = readdir (dir); if (e == NULL) { if (errno == 0) @@ -427,8 +427,8 @@ add_glibc_hwcaps_subdirectories (struct dir_entry *entry, const char *path) continue; /* See if this entry eventually resolves to a directory. */ - struct stat64 st; - if (fstatat64 (dirfd (dir), e->d_name, &st, 0) < 0) + struct stat st; + if (fstatat (dirfd (dir), e->d_name, &st, 0) < 0) /* Ignore unreadable entries. */ continue; @@ -508,8 +508,8 @@ add_dir_1 (const char *line, const char *from_file, int from_line) if (opt_chroot) path = chroot_canon (opt_chroot, path); - struct stat64 stat_buf; - if (path == NULL || stat64 (path, &stat_buf)) + struct stat stat_buf; + if (path == NULL || stat (path, &stat_buf)) { if (opt_verbose) error (0, errno, _("Can't stat %s"), entry->path); @@ -537,15 +537,15 @@ add_dir (const char *line) } static int -chroot_stat (const char *real_path, const char *path, struct stat64 *st) +chroot_stat (const char *real_path, const char *path, struct stat *st) { int ret; char *canon_path; if (!opt_chroot) - return stat64 (real_path, st); + return stat (real_path, st); - ret = lstat64 (real_path, st); + ret = lstat (real_path, st); if (ret || !S_ISLNK (st->st_mode)) return ret; @@ -553,7 +553,7 @@ chroot_stat (const char *real_path, const char *path, struct stat64 *st) if (canon_path == NULL) return -1; - ret = stat64 (canon_path, st); + ret = stat (canon_path, st); free (canon_path); return ret; } @@ -565,7 +565,7 @@ create_links (const char *real_path, const char *path, const char *libname, { char *full_libname, *full_soname; char *real_full_libname, *real_full_soname; - struct stat64 stat_lib, stat_so, lstat_so; + struct stat stat_lib, stat_so, lstat_so; int do_link = 1; int do_remove = 1; /* XXX: The logics in this function should be simplified. */ @@ -600,7 +600,7 @@ create_links (const char *real_path, const char *path, const char *libname, && stat_lib.st_ino == stat_so.st_ino) /* Link is already correct. */ do_link = 0; - else if (lstat64 (full_soname, &lstat_so) == 0 + else if (lstat (full_soname, &lstat_so) == 0 && !S_ISLNK (lstat_so.st_mode)) { error (0, 0, _("%s is not a symbolic link\n"), full_soname); @@ -608,7 +608,7 @@ create_links (const char *real_path, const char *path, const char *libname, do_remove = 0; } } - else if (lstat64 (real_full_soname, &lstat_so) != 0 + else if (lstat (real_full_soname, &lstat_so) != 0 || !S_ISLNK (lstat_so.st_mode)) /* Unless it is a stale symlink, there is no need to remove. */ do_remove = 0; @@ -652,7 +652,7 @@ manual_link (char *library) char *real_library; char *libname; char *soname; - struct stat64 stat_buf; + struct stat stat_buf; int flag; unsigned int osversion; unsigned int isa_level; @@ -706,7 +706,7 @@ manual_link (char *library) } /* Do some sanity checks first. */ - if (lstat64 (real_library, &stat_buf)) + if (lstat (real_library, &stat_buf)) { error (0, errno, _("Cannot lstat %s"), library); free (path); @@ -827,9 +827,9 @@ search_dir (const struct dir_entry *entry) return; } - struct dirent64 *direntry; + struct dirent *direntry; struct dlib_entry *dlibs = NULL; - while ((direntry = readdir64 (dir)) != NULL) + while ((direntry = readdir (dir)) != NULL) { int flag; /* We only look at links and regular files. */ @@ -883,18 +883,18 @@ search_dir (const struct dir_entry *entry) sprintf (real_file_name, "%s/%s", dir_name, direntry->d_name); } - struct stat64 lstat_buf; + struct stat lstat_buf; /* We optimize and try to do the lstat call only if needed. */ if (direntry->d_type != DT_UNKNOWN) lstat_buf.st_mode = DTTOIF (direntry->d_type); else - if (__glibc_unlikely (lstat64 (real_file_name, &lstat_buf))) + if (__glibc_unlikely (lstat (real_file_name, &lstat_buf))) { error (0, errno, _("Cannot lstat %s"), file_name); continue; } - struct stat64 stat_buf; + struct stat stat_buf; bool is_dir; int is_link = S_ISLNK (lstat_buf.st_mode); if (is_link) @@ -912,7 +912,7 @@ search_dir (const struct dir_entry *entry) continue; } } - if (__glibc_unlikely (stat64 (target_name, &stat_buf))) + if (__glibc_unlikely (stat (target_name, &stat_buf))) { if (opt_verbose) error (0, errno, _("Cannot stat %s"), file_name); @@ -940,7 +940,7 @@ search_dir (const struct dir_entry *entry) { if (!is_link && direntry->d_type != DT_UNKNOWN - && __builtin_expect (lstat64 (real_file_name, &lstat_buf), 0)) + && __builtin_expect (lstat (real_file_name, &lstat_buf), 0)) { error (0, errno, _("Cannot lstat %s"), file_name); continue; @@ -969,10 +969,10 @@ search_dir (const struct dir_entry *entry) else real_name = real_file_name; - /* Call lstat64 if not done yet. */ + /* Call lstat if not done yet. */ if (!is_link && direntry->d_type != DT_UNKNOWN - && __builtin_expect (lstat64 (real_file_name, &lstat_buf), 0)) + && __builtin_expect (lstat (real_file_name, &lstat_buf), 0)) { error (0, errno, _("Cannot lstat %s"), file_name); continue; @@ -1302,25 +1302,25 @@ parse_conf_include (const char *config_file, unsigned int lineno, pattern = copy; } - glob64_t gl; + glob_t gl; int result; if (do_chroot && opt_chroot) { char *canon = chroot_canon (opt_chroot, pattern); if (canon == NULL) return; - result = glob64 (canon, 0, NULL, &gl); + result = glob (canon, 0, NULL, &gl); free (canon); } else - result = glob64 (pattern, 0, NULL, &gl); + result = glob (pattern, 0, NULL, &gl); switch (result) { case 0: for (size_t i = 0; i < gl.gl_pathc; ++i) parse_conf (gl.gl_pathv[i], false); - globfree64 (&gl); + globfree (&gl); break; case GLOB_NOMATCH: diff --git a/elf/readlib.c b/elf/readlib.c index 7383c23249..8901de2684 100644 --- a/elf/readlib.c +++ b/elf/readlib.c @@ -76,10 +76,10 @@ int process_file (const char *real_file_name, const char *file_name, const char *lib, int *flag, unsigned int *osversion, unsigned int *isa_level, char **soname, int is_link, - struct stat64 *stat_buf) + struct stat *stat_buf) { FILE *file; - struct stat64 statbuf; + struct stat statbuf; void *file_contents; int ret; ElfW(Ehdr) *elf_header; @@ -99,7 +99,7 @@ process_file (const char *real_file_name, const char *file_name, return 1; } - if (fstat64 (fileno (file), &statbuf) < 0) + if (fstat (fileno (file), &statbuf) < 0) { error (0, 0, _("Cannot fstat file %s.\n"), file_name); fclose (file); diff --git a/elf/sln.c b/elf/sln.c index 26f371a493..f71321d565 100644 --- a/elf/sln.c +++ b/elf/sln.c @@ -153,11 +153,11 @@ makesymlinks (const char *file) static int makesymlink (const char *src, const char *dest) { - struct stat64 stats; + struct stat stats; const char *error; /* Destination must not be a directory. */ - if (lstat64 (dest, &stats) == 0) + if (lstat (dest, &stats) == 0) { if (S_ISDIR (stats.st_mode)) { diff --git a/elf/sprof.c b/elf/sprof.c index bc049c8f79..71ba33a89d 100644 --- a/elf/sprof.c +++ b/elf/sprof.c @@ -745,7 +745,7 @@ load_profdata (const char *name, struct shobj *shobj) { struct profdata *result; int fd; - struct stat64 st; + struct stat st; void *addr; uint32_t *narcsp; size_t fromlimit; @@ -784,7 +784,7 @@ load_profdata (const char *name, struct shobj *shobj) /* We have found the file, now make sure it is the right one for the data file. */ - if (fstat64 (fd, &st) < 0) + if (fstat (fd, &st) < 0) { error (0, errno, _("while stat'ing profiling data file")); close (fd); diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h index 3ab757077d..c0eb95bcf9 100644 --- a/sysdeps/generic/ldconfig.h +++ b/sysdeps/generic/ldconfig.h @@ -79,11 +79,11 @@ extern void init_aux_cache (void); extern void load_aux_cache (const char *aux_cache_name); -extern int search_aux_cache (struct stat64 *stat_buf, int *flags, +extern int search_aux_cache (struct stat *stat_buf, int *flags, unsigned int *osversion, unsigned int *isa_level, char **soname); -extern void add_to_aux_cache (struct stat64 *stat_buf, int flags, +extern void add_to_aux_cache (struct stat *stat_buf, int flags, unsigned int osversion, unsigned int isa_level, const char *soname); @@ -94,7 +94,7 @@ extern int process_file (const char *real_file_name, const char *file_name, const char *lib, int *flag, unsigned int *osversion, unsigned int *isa_level, char **soname, int is_link, - struct stat64 *stat_buf); + struct stat *stat_buf); extern char *implicit_soname (const char *lib, int flag);