ICE w/ current CVS, PIC and dwarf2, ix86
Zack Weinberg
zack@rabi.columbia.edu
Wed Jun 16 10:11:00 GMT 1999
The appended piece of code gets an ICE when compiled with -O -fPIC
-gdwarf-2. -gstabs works fine, as does non-pic.
Reading specs from .../gcc-lib/i586-pc-linux-gnu/gcc-2.96/specs
gcc version gcc-2.96 19990614 (experimental)
.../gcc-lib/i586-pc-linux-gnu/gcc-2.96/cc1 malloc.i -quiet -gdwarf-2 -O2
-version -fPIC -o malloc.s
GNU C version gcc-2.96 19990614 (experimental) (i586-pc-linux-gnu)
compiled by GNU C version gcc-2.96 19990614 (experimental).
malloc.i: In function `main_trim':
malloc.i:66: Internal compiler error, output_operand_lossage
`invalid expression as operand'
This is breaking libc compiles.
zw
typedef long int ptrdiff_t;
typedef unsigned int size_t;
typedef int mutex_t;
struct malloc_chunk
{
size_t prev_size;
size_t size;
struct malloc_chunk *fd;
struct malloc_chunk *bk;
};
typedef struct malloc_chunk *mchunkptr;
typedef struct malloc_chunk *mbinptr;
typedef struct _arena
{
mbinptr av[2 * 128 + 2];
struct _arena *next;
size_t size;
mutex_t mutex;
}
arena;
static arena main_arena;
static size_t __libc_pagesize;
extern void *(*__morecore) (ptrdiff_t __size);
extern void (*__after_morecore_hook) (void);
static char *sbrk_base = (char *) (-1);
int
__attribute__ ((regparm (3), stdcall))
main_trim (size_t pad)
{
mchunkptr top_chunk;
long top_size;
long extra;
char *current_brk;
char *new_brk;
unsigned long pagesz = __libc_pagesize;
top_chunk = (((mbinptr) ((char *) &(((&main_arena)->av)[2 * (0) + 2]) - 2
* (sizeof (size_t))))->fd);
top_size = ((top_chunk)->size & ~((0x1 | 0x2)));
extra = ((top_size - pad - (sizeof (struct malloc_chunk)) + (pagesz - 1))
/ pagesz - 1) * pagesz;
if (extra < (long) pagesz)
return 0;
current_brk = (char *) ((*__morecore) (0));
if (current_brk != (char *) (top_chunk) + top_size)
return 0;
new_brk = (char *) ((*__morecore) (-extra));
if (__after_morecore_hook)
(*__after_morecore_hook) ();
if (new_brk == (char *) (0))
{
current_brk = (char *) ((*__morecore) (0));
top_size = current_brk - (char *) top_chunk;
if (top_size >= (long) (sizeof (struct malloc_chunk)))
{
(main_arena.size) = current_brk - sbrk_base;
((top_chunk)->size = (top_size | 0x1));
}
return 0;
}
(main_arena.size) -= extra;
((top_chunk)->size = ((top_size - extra) | 0x1));
return 1;
}
More information about the Gcc-bugs
mailing list