diff options
author | Hans-Peter Nilsson <hp@bitrange.com> | 2019-07-11 00:11:09 -0400 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2019-10-03 17:04:55 +0100 |
commit | a2230b5e626b301e1f5f0f7122fe4038c9eb8428 (patch) | |
tree | 183a677c755754c2a6674f3a0824c937529c6338 /libctf | |
parent | gdb: Don't ignore all SIGSTOP when the signal handler is set to pass (diff) | |
download | binutils-gdb-a2230b5e626b301e1f5f0f7122fe4038c9eb8428.tar.gz binutils-gdb-a2230b5e626b301e1f5f0f7122fe4038c9eb8428.tar.bz2 binutils-gdb-a2230b5e626b301e1f5f0f7122fe4038c9eb8428.zip |
libctf: make it compile for old glibc
With a glibc before 2.9 (such as 2.8), there's <endian.h> but no
htole64 or le64toh, so you get, compiling binutils for any target:
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes \
-Wshadow -Werror -I/x/binutils/../zlib -g -O2 -o objdump \
objdump.o dwarf.o prdbg.o rddbg.o debug.o stabs.o rdcoff.o \
bucomm.o version.o filemode.o elfcomm.o ../opcodes/.libs/libopcodes.a \
../libctf/libctf.a ../bfd/.libs/libbfd.a -L/x/obj/b/zlib -lz ../libiberty/libiberty.a -ldl
../libctf/libctf.a(ctf-archive.o): In function `ctf_archive_raw_iter_internal':
/x/src/libctf/ctf-archive.c:543: undefined reference to `le64toh'
/x/src/libctf/ctf-archive.c:550: undefined reference to `le64toh'
/x/src/libctf/ctf-archive.c:551: undefined reference to `le64toh'
/x/src/libctf/ctf-archive.c:551: undefined reference to `le64toh'
/x/src/libctf/ctf-archive.c:554: undefined reference to `le64toh'
../libctf/libctf.a(ctf-archive.o):/x/src/libctf/ctf-archive.c:545: more undefined references to `le64toh' follow
(etc)
Also, I see no bswap_identity_64 *anywhere* except in libctf/swap.h
(including current glibc) and I don't think calling an "identity"-
function is better than just plain "#define foo(x) (x)" anyway.
(Where does the idea of a bytestap.h bswap_identity_64 come from?)
Speaking of that, I should mention that I instrumented the condition
to observe that the WORDS_BIGENDIAN case passes too for a presumed
big-endian target and glibc-2.8: there is a bswap_64 present for that
version. Curiously, no test-case regressed with that instrumentation.
For the record, constructing binary blobs using text source to run
tests on, can be done by linking to --oformat binary (with most ELF
targets), but I guess that's seen as unnecessary roundabout perhaps
checking in binary files in the test-suite would be ok these days.
[...]
[nca: trimmed commit log slightly, updated changelog]
v5: fix tabdamage.
libctf/
* ctf-endian.h: Don't assume htole64 and le64toh are always
present if HAVE_ENDIAN_H; also check if htole64 is defined.
[!WORDS_BIGENDIAN] (htole64, le64toh): Define as identity,
not bswap_identity_64.
Diffstat (limited to 'libctf')
-rw-r--r-- | libctf/ChangeLog | 7 | ||||
-rw-r--r-- | libctf/ctf-endian.h | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog index 8a82ed0565f..08eb02bea01 100644 --- a/libctf/ChangeLog +++ b/libctf/ChangeLog @@ -1,3 +1,10 @@ +2019-07-11 Hans-Peter Nilsson <hp@bitrange.com> + + * ctf-endian.h: Don't assume htole64 and le64toh are always + present if HAVE_ENDIAN_H; also check if htole64 is defined. + [!WORDS_BIGENDIAN] (htole64, le64toh): Define as identity, + not bswap_identity_64. + 2019-09-18 Alan Modra <amodra@gmail.com> * ctf-open-bfd.c: Update throughout for bfd section macro changes. diff --git a/libctf/ctf-endian.h b/libctf/ctf-endian.h index ec177d1bdd8..f1cc527a080 100644 --- a/libctf/ctf-endian.h +++ b/libctf/ctf-endian.h @@ -24,10 +24,10 @@ #include <stdint.h> #include "swap.h" -#ifndef HAVE_ENDIAN_H +#if !defined (HAVE_ENDIAN_H) || !defined (htole64) #ifndef WORDS_BIGENDIAN -# define htole64(x) bswap_identity_64 ((x)) -# define le64toh(x) bswap_identity_64 ((x)) +# define htole64(x) (x) +# define le64toh(x) (x) #else # define htole64(x) bswap_64 ((x)) # define le64toh(x) bswap_64 ((x)) |