aboutsummaryrefslogtreecommitdiff
path: root/gcc/fixinc
diff options
context:
space:
mode:
authorBruce Korb <bkorb@gnu.org>2000-09-05 18:29:56 +0000
committerBruce Korb <korbb@gcc.gnu.org>2000-09-05 18:29:56 +0000
commita6efbeceaa32697481a64af7790a07e80c43a667 (patch)
treeeadd63265629d02cd0806c7616c488e6e56668ba /gcc/fixinc
parent0bb06853c3f6e4d4ff811f756245d0a4d8d0a2ee (diff)
downloadgcc-a6efbeceaa32697481a64af7790a07e80c43a667.zip
gcc-a6efbeceaa32697481a64af7790a07e80c43a667.tar.gz
gcc-a6efbeceaa32697481a64af7790a07e80c43a667.tar.bz2
always read header files with poorly chosen sizes
From-SVN: r36163
Diffstat (limited to 'gcc/fixinc')
-rw-r--r--gcc/fixinc/fixincl.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/fixinc/fixincl.c b/gcc/fixinc/fixincl.c
index 9736537..ad5d23a 100644
--- a/gcc/fixinc/fixincl.c
+++ b/gcc/fixinc/fixincl.c
@@ -338,6 +338,10 @@ load_file ( fname )
if (stbf.st_size == 0)
return (char*)NULL;
+ /* Make the data map size one larger than the file size for documentation
+ purposes. Truth is that there will be a following NUL character if
+ the file size is not a multiple of the page size. If it is a multiple,
+ then this adjustment sometimes fails anyway. */
data_map_size = stbf.st_size+1;
data_map_fd = open (fname, O_RDONLY);
ttl_data_size += data_map_size-1;
@@ -352,8 +356,14 @@ load_file ( fname )
#ifdef HAVE_MMAP_FILE
curr_data_mapped = BOOL_TRUE;
- res = (char*)mmap ((void*)NULL, data_map_size, PROT_READ, MAP_PRIVATE,
- data_map_fd, 0);
+
+ /* IF the file size is a multiple of the page size,
+ THEN sometimes you will seg fault trying to access a trailing byte */
+ if ((stbf.st_size & (PAGESIZE-1)) == 0)
+ res = (char*)BAD_ADDR;
+ else
+ res = (char*)mmap ((void*)NULL, data_map_size, PROT_READ,
+ MAP_PRIVATE, data_map_fd, 0);
if (res == (char*)BAD_ADDR)
{
curr_data_mapped = BOOL_FALSE;