* wrong code generation :
@ 2002-10-17 21:59 Dinesh Nagpure
0 siblings, 0 replies; only message in thread
From: Dinesh Nagpure @ 2002-10-17 21:59 UTC (permalink / raw)
To: 'gcc-help@gcc.gnu.org'
Greetings,
While building Linux kernel v 2.4.16 for RM5231A processor I am facing some
problems in the way code is generated for memcpy. I see some unaligned
accesses beging done and also the inline code for memcpy doesn't seem to be
given proper destination address. I also tried the -mmemcpy switch without
much success, here is what I see with -mmemcpy. The offending code is in
console_init( ) as below:
void __init console_init(void)
{
memset(ldiscs, 0, sizeof(ldiscs));
(void) tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY);
memset(&tty_std_termios, 0, sizeof(struct termios));
memcpy(tty_std_termios.c_cc, INIT_C_CC, NCCS);
printk("tty_std_termios is at %p\n", &tty_std_termios);
|
few more printk( ) calls etc.
}
Here is the code generated for the function console_init( )
80206d00 <console_init>:
80206d00: 27bdffc8 addiu sp,sp,-56
80206d04: 24060400 li a2,1024
80206d08: 3c048029 lui a0,0x8029
80206d0c: 2484b140 addiu a0,a0,-20160
80206d10: afbf0034 sw ra,52(sp)
80206d14: afbe0030 sw s8,48(sp)
80206d18: afb7002c sw s7,44(sp)
80206d1c: afb60028 sw s6,40(sp)
80206d20: afb50024 sw s5,36(sp)
80206d24: afb40020 sw s4,32(sp)
80206d28: afb3001c sw s3,28(sp)
80206d2c: afb20018 sw s2,24(sp)
80206d30: afb10014 sw s1,20(sp)
80206d34: afb00010 sw s0,16(sp)
80206d38: 3c108029 lui s0,0x8029
80206d3c: 2610b114 addiu s0,s0,-20204
80206d40: 0c078bc0 jal 801e2f00 <memset>
80206d44: 00002821 move a1,zero
80206d48: 3c058022 lui a1,0x8022
80206d4c: 24a59480 addiu a1,a1,-27520
80206d50: 0c06117c jal 801845f0 <tty_register_ldisc>
80206d54: 00002021 move a0,zero
80206d58: 02002021 move a0,s0
80206d5c: 00002821 move a1,zero
80206d60: 0c078bc0 jal 801e2f00 <memset>
80206d64: 24060028 li a2,40
80206d68: 24060017 li a2,23
80206d6c: 3c05801f lui a1,0x801f
80206d70: 24a5fcc8 addiu a1,a1,-824
80206d74: 0c0789c8 jal 801e2720 <memcpy>
80206d78: 26040011 addiu a0,s0,17 /* this bugs me a lot */
80206d7c: 3c04801f lui a0,0x801f
80206d80: 2484fcdc addiu a0,a0,-804
80206d84: 0c046ddd jal 8011b774 <printk>
80206d88: 02002821 move a1,s0
80206d8c: 3c11801f lui s1,0x801f
80206d90: 2631fcf8 addiu s1,s1,-776
80206d94: 92050011 lbu a1,17(s0)
The destination address for memcpy is c_cc array in the termios structure :
typedef unsigned char cc_t;
typedef unsigned long speed_t;
typedef unsigned long tcflag_t;
/*
* The ABI says nothing about NCC but seems to use NCCS as
* replacement for it in struct termio
*/
#define NCCS 23
struct termios {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
// cc_t c_cc[NCCS]; /* control characters */
/*
* Seems nonexistent in the ABI, but Linux assumes existence ...
*/
cc_t c_line; /* line discipline */
cc_t c_cc[NCCS]; /* control characters */
};
Source for memcpy( ) is in termios.h as:
#define INIT_C_CC
"\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0"
As a result memcpy( ) fails to copy to the destination and c_cc remains all
zeros from memset( ). I see memcpy( ) tries to do some alignment but
apparently fails. If I flip the c_line and c_cc positions then memcpy( )
does work.
I am using gcc-3.0.2 and binutils-2.11.92.0.7. To me this seems to be some
gcc code generation issue. Will someone pls tell me if the toolchain I am
using is good enough or else what should I be using? I don't see any
additional flags also that would slove my problem.
Thanks,
Dinesh
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-10-18 4:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-17 21:59 wrong code generation : Dinesh Nagpure
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).