* [parisc-linux] hppa64 gcc sizeof() bug?
@ 2000-12-06 11:52 Richard Hirst
2000-12-06 12:18 ` Richard Hirst
2000-12-06 12:44 ` Richard Hirst
0 siblings, 2 replies; 4+ messages in thread
From: Richard Hirst @ 2000-12-06 11:52 UTC (permalink / raw)
To: Alan Modra; +Cc: parisc-linux
Hi Alan,
The following shows the compiler getting confused over the size
of a struct. This is with a gcc/binutils built since the last
fix you did for me.
Richard
[rhirst@rhirst play]$ cat tc.c
typedef unsigned int u32;
#define NULL ((void *)0)
struct kernel_sym32 {
u32 value;
char name[60];
};
extern int sys_get_kernel_syms(void *);
extern int thing(struct kernel_sym32 *table);
int sys32_get_kernel_syms(struct kernel_sym32 *table)
{
int len, i;
len = sizeof (struct kernel_sym32);
for (i = 0; i < len; i++, table += sizeof (struct kernel_sym32)) {
if (thing(table))
break;
}
return i;
}
[rhirst@rhirst play]$ hppa64-linux-gcc -S -o tc.s -O2 tc.c
[rhirst@rhirst play]$ cat tc.s
.LEVEL 2.0w
gcc2_compiled.:
.text
.align 8
.globl sys32_get_kernel_syms
.type sys32_get_kernel_syms,@function
sys32_get_kernel_syms:
.PROC
.CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=6
.ENTRY
std %r2,-16(%r30)
ldo 128(%r30),%r30
std %r6,-128(%r30)
ldi 64,%r6 <<< Good, struct is 64 bytes
std %r5,-120(%r30)
ldi 0,%r5
std %r4,-112(%r30)
copy %r27,%r4
std %r3,-104(%r30)
copy %r26,%r3
.L3:
copy %r3,%r26
ldo 4096(%r3),%r3 <<< BAD struct is not 4096 bytes!
cmpb,<= %r6,%r5,.L4
ldo -16(%r30),%r29
b,l thing,%r2
nop
copy %r4,%r27
cmpib,= 0,%r28,.L5
ldo 1(%r5),%r19
.L4:
copy %r5,%r28
ldd -144(%r30),%r2
ldd -120(%r30),%r5
ldd -112(%r30),%r4
ldd -104(%r30),%r3
bve (%r2)
ldd,mb -128(%r30),%r6
.L5:
b .L3
extrd,s %r19,63,32,%r5
.EXIT
.PROCEND
.Lfe1:
.size sys32_get_kernel_syms,.Lfe1-sys32_get_kernel_syms
.ident "GCC: (GNU) 2.96 20000925 (experimental)"
[rhirst@rhirst play]$
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [parisc-linux] hppa64 gcc sizeof() bug?
2000-12-06 11:52 [parisc-linux] hppa64 gcc sizeof() bug? Richard Hirst
@ 2000-12-06 12:18 ` Richard Hirst
2000-12-06 18:28 ` Grant Grundler
2000-12-06 12:44 ` Richard Hirst
1 sibling, 1 reply; 4+ messages in thread
From: Richard Hirst @ 2000-12-06 12:18 UTC (permalink / raw)
To: Alan Modra; +Cc: parisc-linux
On Wed, Dec 06, 2000 at 11:52:03AM +0000, Richard Hirst wrote:
> Hi Alan,
> The following shows the compiler getting confused over the size
> of a struct. This is with a gcc/binutils built since the last
> fix you did for me.
>
> Richard
>
>
> [rhirst@rhirst play]$ cat tc.c
>
>
> typedef unsigned int u32;
> #define NULL ((void *)0)
>
> struct kernel_sym32 {
> u32 value;
> char name[60];
> };
>
> extern int sys_get_kernel_syms(void *);
> extern int thing(struct kernel_sym32 *table);
>
> int sys32_get_kernel_syms(struct kernel_sym32 *table)
> {
> int len, i;
>
> len = sizeof (struct kernel_sym32);
> for (i = 0; i < len; i++, table += sizeof (struct kernel_sym32)) {
> if (thing(table))
> break;
> }
> return i;
> }
Just changed it to 'table += 64' and it still generates code that
adds 4096, so sizeof is not relevant.
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [parisc-linux] hppa64 gcc sizeof() bug?
2000-12-06 11:52 [parisc-linux] hppa64 gcc sizeof() bug? Richard Hirst
2000-12-06 12:18 ` Richard Hirst
@ 2000-12-06 12:44 ` Richard Hirst
1 sibling, 0 replies; 4+ messages in thread
From: Richard Hirst @ 2000-12-06 12:44 UTC (permalink / raw)
To: parisc-linux
On Wed, Dec 06, 2000 at 11:52:03AM +0000, Richard Hirst wrote:
> Hi Alan,
> The following shows the compiler getting confused over the size
> of a struct. This is with a gcc/binutils built since the last
> fix you did for me.
As Alan has kindly pointed out to me, I goofed. In my defence, I
did copy the garbage code from the sparc64 port ;)
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [parisc-linux] hppa64 gcc sizeof() bug?
2000-12-06 12:18 ` Richard Hirst
@ 2000-12-06 18:28 ` Grant Grundler
0 siblings, 0 replies; 4+ messages in thread
From: Grant Grundler @ 2000-12-06 18:28 UTC (permalink / raw)
To: Richard Hirst; +Cc: Alan Modra, parisc-linux
Richard Hirst wrote:
> > int sys32_get_kernel_syms(struct kernel_sym32 *table)
...
> Just changed it to 'table += 64' and it still generates code that
> adds 4096, so sizeof is not relevant.
Right. sizeof() works fine.
table points to something that is 4096/64 (64 bytes) in size.
table+=1 results in adding 4096/64 to table.
The code should read "((char *) table) += 64" or "table++".
grant
Grant Grundler
Unix Systems Enablement Lab
+1.408.447.7253
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-12-06 18:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-12-06 11:52 [parisc-linux] hppa64 gcc sizeof() bug? Richard Hirst
2000-12-06 12:18 ` Richard Hirst
2000-12-06 18:28 ` Grant Grundler
2000-12-06 12:44 ` Richard Hirst
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.