This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Should NBPG be unconditionally undefined to avoid references to PAGE_SIZE?


This is probably a better place to discuss this than bug-binutils. I am trying to make it easier for people to build cross-compile tool chains for all 20+ targets supported by the Linux kernel, using the currently released versions of binutils, glibc, gcc and the kernel. When I build binutils for alpha as part of a cross-compile tool chain everything is fine because (host != target) in bfd/configure and thus COREFILE= COREFLAG= TRAD_HEADER= are not set so trad-core.c is not built. When I use that tool chain to build a Canadian cross to install in the sysroot, however, binutils fails to build because NBPG is set to PAGE_SIZE in <sys/user.h> in bfd/trad-core.c. It would be easy enough to patch that header, but I really think things should build out-of-the-box. This same problem can be found in bugzilla for m68k, so others have tripped over it too.

As shown below, glibc-2.6.1 still defines NBPG to PAGE_SIZE in many cases. In reality, PAGE_SIZE is not a constant value for some processors. For this reason it has been removed from the exported kernel headers. The obvious change is to use getpagesize() instead. This should get fixed in glibc at some point, but as of now, including <sys/user.h> in bfd/trad-core.c can set NBPG to PAGE_SIZE which causes a build failure with some configs. The undef statement show with <---- got things building for me again with binutils-2.18.50. Is there some reason this is not unconditional now that PAGE_SIZE has gone away in the kernel headers? From a code correctness point of view I don't see how always using getpagesize() is not better than relying on a possibly flakey definition of NBPG from elsewhere, for any modern kernel or glibc versions. Should something similar make it into a suitable central place in the next release of binutils so no target by target fixups are required and it will build more consistently regardless of the version the libc headers? Obviously not a problem to distro users, but a big help to the roll-your-own cross-compiler crowd.

Thanks - Steve


--- From bfd/trad-core.c --- #include <signal.h>

#include <sys/user.h> /* After a.out.h */
#undef NBPG /* Do not let <sys/user.h> set this to PAGE_SIZE */ <--------------------------


#ifdef TRAD_HEADER
#include TRAD_HEADER
#endif

#ifndef NBPG
# define NBPG getpagesize()
#endif

--- From glibc-2.6.1 for multiple Linux ports ---
find . -name user.h -exec grep PAGE_SIZE {} \;  -print
#define NBPG                   PAGE_SIZE /* XXX 4096 maybe? */
./sparc64-linux/usr/include/asm-sparc64/user.h
#define NBPG                    PAGE_SIZE
./m32r-linux/usr/include/asm/user.h
#define NBPG PAGE_SIZE
./s390-linux/usr/include/asm/user.h
#define NBPG                    PAGE_SIZE
./sh64-linux/usr/include/asm/user.h
#define NBPG PAGE_SIZE
./bfin-linux-uclibc/usr/include/asm/user.h
#define NBPG                    PAGE_SIZE
./cris-linux/usr/include/asm/user.h
#define NBPG                    PAGE_SIZE
./avr-linux/usr/include/asm/user.h
#define NBPG                    PAGE_SIZE
./frv-linux/usr/include/asm/user.h
#define NBPG PAGE_SIZE
./x86_64-linux/usr/include/asm-x86_64/user.h
#define NBPG PAGE_SIZE
./x86_64-linux/usr/include/asm-i386/user.h
#define NBPG                    PAGE_SIZE
./alpha-linux/usr/include/asm/user.h
#define NBPG                    PAGE_SIZE
./alpha-linux/usr/include/sys/user.h
#define NBPG                    PAGE_SIZE
./sh-linux/usr/include/asm/user.h
#define NBPG PAGE_SIZE
./i386-linux/usr/include/asm/user.h
#define NBPG                    PAGE_SIZE
./ia64-linux/usr/include/asm/user.h
#define NBPG PAGE_SIZE
./h8300-elf/usr/include/asm/user.h
#define NBPG PAGE_SIZE
./arm-linux/usr/include/asm/user.h


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]