This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
check-textrel
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: libc-alpha at sources dot redhat dot com
- Cc: Steve Munroe <sjmunroe at us dot ibm dot com>
- Date: Tue, 11 Feb 2003 14:57:31 +1030
- Subject: check-textrel
This test breaks when cross-compiling powerpc64-linux glibc from
a powerpc-linux host. Problem is that e_phoff is 64 bits while
pread expects a 32-bit offset. The following patch fixes this,
arranges for pread to be prototyped, and kills compiler warnings
about && within ||.
* elf/check-textrel.c (_XOPEN_SOURCE, _BSD_SOURCE): Define.
(SWAP): Warning fix.
(handle_file): Assign e_phoff to a temp to ensure correct size.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
--- libc-current/elf/check-textrel.c 2003-02-11 14:09:48.000000000 +1030
+++ libc-ppc64/elf/check-textrel.c 2003-02-11 14:31:08.000000000 +1030
@@ -18,6 +18,9 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#define _XOPEN_SOURCE 500
+#define _BSD_SOURCE 1
+
#include <byteswap.h>
#include <elf.h>
#include <endian.h>
@@ -38,8 +41,10 @@
# define __E(name, bits) Elf##bits##_##name
# define SWAP(val) \
({ __typeof (val) __res; \
- if ((ehdr.e_ident[EI_DATA] == ELFDATA2MSB && BYTE_ORDER == LITTLE_ENDIAN \
- || ehdr.e_ident[EI_DATA] == ELFDATA2LSB && BYTE_ORDER == BIG_ENDIAN)\
+ if (((ehdr.e_ident[EI_DATA] == ELFDATA2MSB \
+ && BYTE_ORDER == LITTLE_ENDIAN) \
+ || (ehdr.e_ident[EI_DATA] == ELFDATA2LSB \
+ && BYTE_ORDER == BIG_ENDIAN)) \
&& sizeof (val) != 1) \
{ \
if (sizeof (val) == 2) \
@@ -68,11 +73,11 @@ AB(handle_file) (const char *fname, int
const size_t phnum = SWAP (ehdr.e_phnum);
const size_t phentsize = SWAP (ehdr.e_phentsize);
+ const off_t phoff = SWAP (ehdr.e_phoff);
/* Read the program header. */
E(Phdr) *phdr = alloca (phentsize * phnum);
- if (pread (fd, phdr, phentsize * phnum, SWAP (ehdr.e_phoff))
- != phentsize * phnum)
+ if (pread (fd, phdr, phentsize * phnum, phoff) != phentsize * phnum)
goto read_error;
/* Search for the PT_DYNAMIC entry. */