mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-28 07:08:01 +08:00
Changes for mmap; details in change log.
Added some new interfaces, and a new entry in the target vector. Under the new interfaces, mmap will be used if available, otherwise malloc/seek/read, as before. Old interfaces all still intact. Most configurations (including all used by "--enable-targets=all") simply changed to call the default routine for that entry in the target vector. I might've missed some targets only included in special configurations. Support for a.out symbol and string table reading now goes through new interfaces, and will use mmap when available. Linker hooks (e.g., avoiding reallocation under malloc) not ready yet.
This commit is contained in:
152
bfd/configure
vendored
152
bfd/configure
vendored
@ -1502,6 +1502,158 @@ test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
|
||||
test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
|
||||
|
||||
|
||||
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
|
||||
if eval "test \"`echo '$''{'ac_cv_func_mmap'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then
|
||||
ac_cv_func_mmap=no
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1514 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
/* Thanks to Mike Haertel and Jim Avera for this test. */
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifdef BSD
|
||||
# ifndef BSD4_1
|
||||
# define HAVE_GETPAGESIZE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETPAGESIZE
|
||||
# include <sys/param.h>
|
||||
# ifdef EXEC_PAGESIZE
|
||||
# define getpagesize() EXEC_PAGESIZE
|
||||
# else
|
||||
# ifdef NBPG
|
||||
# define getpagesize() NBPG * CLSIZE
|
||||
# ifndef CLSIZE
|
||||
# define CLSIZE 1
|
||||
# endif
|
||||
# else
|
||||
# ifdef NBPC
|
||||
# define getpagesize() NBPC
|
||||
# else
|
||||
# define getpagesize() PAGESIZE /* SVR4 */
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __osf__
|
||||
# define valloc malloc
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { void *valloc(unsigned), *malloc(unsigned); }
|
||||
#else
|
||||
char *valloc(), *malloc();
|
||||
#endif
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
char *buf1, *buf2, *buf3;
|
||||
int i = getpagesize(), j;
|
||||
int i2 = getpagesize()*2;
|
||||
int fd;
|
||||
|
||||
buf1 = (char *)valloc(i2);
|
||||
buf2 = (char *)valloc(i);
|
||||
buf3 = (char *)malloc(i2);
|
||||
for (j = 0; j < i2; ++j)
|
||||
*(buf1 + j) = rand();
|
||||
fd = open("conftestmmap", O_CREAT | O_RDWR, 0666);
|
||||
write(fd, buf1, i2);
|
||||
mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0);
|
||||
for (j = 0; j < i; ++j)
|
||||
if (*(buf1 + j) != *(buf2 + j))
|
||||
exit(1);
|
||||
lseek(fd, (long)i, 0);
|
||||
read(fd, buf2, i); /* read into mapped memory -- file should not change */
|
||||
/* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */
|
||||
lseek(fd, (long)0, 0);
|
||||
read(fd, buf3, i2);
|
||||
for (j = 0; j < i2; ++j)
|
||||
if (*(buf1 + j) != *(buf3 + j))
|
||||
exit(1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
EOF
|
||||
eval $ac_link
|
||||
if test -s conftest && (./conftest; exit) 2>/dev/null; then
|
||||
ac_cv_func_mmap=yes
|
||||
else
|
||||
ac_cv_func_mmap=no
|
||||
fi
|
||||
fi
|
||||
rm -fr conftest*
|
||||
fi
|
||||
echo "$ac_t""$ac_cv_func_mmap" 1>&6
|
||||
if test $ac_cv_func_mmap = yes; then
|
||||
cat >> confdefs.h <<\EOF
|
||||
#define HAVE_MMAP 1
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
for ac_func in madvise mprotect
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1613 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
#include <assert.h>
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
char $ac_func();
|
||||
|
||||
int main() { return 0; }
|
||||
int t() {
|
||||
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
|
||||
choke me
|
||||
#else
|
||||
$ac_func();
|
||||
#endif
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if eval $ac_link; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=no"
|
||||
fi
|
||||
rm -f conftest*
|
||||
|
||||
fi
|
||||
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
|
||||
echo "$ac_t""yes" 1>&6
|
||||
ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'`
|
||||
cat >> confdefs.h <<EOF
|
||||
#define $ac_tr_func 1
|
||||
EOF
|
||||
|
||||
else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
rm -f doc/config.status
|
||||
trap '' 1 2 15
|
||||
cat > confcache <<\EOF
|
||||
|
Reference in New Issue
Block a user