[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#378628: gcc-4.0: GCC 4.0.3 miscompile debugging information

This bug can also be reproduced without systemtap. Simple demo attached.
Usage (on i386):

% gcc-4.0 -g -mregparm=2 -O2 driver.c 1.c
% gdb ./a.out
GNU gdb 6.4.90-debian
(gdb) br sys_open
Breakpoint 1 at 0x8048363: file 1.c, line 5.
(gdb) run
Starting program: /tmp/out/a.out

Breakpoint 1, sys_open (filename=0xbff7f024 "��) at 1.c:5
5       {

The interesting thing here is how filename argument value is displayed.
This bug cannot be reproduced with gcc-4.1. GDB also displays correct
contents of 'filename' if files compiled without -O2.

There is also one mail that suggests that gcc generates debug info as if
'filename' was stored in register (but it is stored in stack due to regpram(0)


17 липня 2006 о 18:12 -0300 Tiago Macambira написав(-ла):
> Linux kernels compiled with gcc 4.0.3 have invalid debuging information.
> More information on this issue and how to verify this error can be
> obtained in bug #378621. I'll also have to use gcc 4.0.3 to compile a
> kernel with CONFIG_DEBUG_INFO, CONFIG_KPROBES, and optionally
> CONFIG_RELAY. You also need the resulting kernel unstripped vmlinux.
> Notice that bug 378621 was filed against systemtap but the issue here is
> gcc 4.0. GCC 4.1 seems to provide correct/good debug information though.
> Besides, although this error was spoted in a kernel compiled with 4.0,

Eugeniy Meshcheryakov
#define asmlinkage __attribute__((regparm(0)))

extern asmlinkage long sys_open(const char *filename);

long do_sys_open(const char *filename)
	return 0;

int main(int arc, char **argv)
	return sys_open("/tmp/out");

extern long do_sys_open(const char *);

#define asmlinkage __attribute__((regparm(0)))
asmlinkage long sys_open(const char *filename)
	long ret;
	ret = do_sys_open(filename);
	return ret;

Attachment: signature.asc
Description: Digital signature

Reply to: