readelf: use fseeko64 or fseeko if possible

Changes readelf to make use first of fseeko64 and then fseeko,
depending on which of those is available. If neither is available,
reverts to the previous behavior of using fseek.

This is necessary when building readelf for LLP64 systems, where a
long will only be 32 bits wide. If the elf file in question is >= 2 GiB,
that is greater than the max long value and therefore fseek will fail
indicating that the offset is negative. On such systems, making use of
fseeko64 or fseeko will result in the ability so seek past the 2 GiB
max long boundary.

Note that large archive handling in readelf remains to be fixed.
This commit is contained in:
Brett Werling
2022-11-17 08:34:19 -06:00
committed by Alan Modra
parent 38c917d808
commit d82e33decc
3 changed files with 26 additions and 12 deletions

2
binutils/configure vendored
View File

@@ -13155,7 +13155,7 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h
fi
rm -f conftest.mmap conftest.txt
for ac_func in getc_unlocked mkdtemp mkstemp utimensat utimes
for ac_func in getc_unlocked mkdtemp mkstemp utimensat utimes fseeko fseeko64
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"