Subject: Re:

From: John Ballance <[email-masked]>
Date: Wed, 18 Nov 1998 02:47:43

Phil
in a fraught attempt to find out whats happening, I've gone back to a
clean beginning. 
I enclose a listing of just what happened.. Its as an enclosure because
of linitations
in my current e-mail setup

as you will see.. its getting there, but it seems that the jump to elf
code is rather large
and seems to need lots of unepected stuff

I look forward to your comments.. 
Thanks

-- 
                      John Ballance
 Castle Technology, Ore Trading Estate, Woodbridge Road, Framlingham,
Suffolk UK IP13 9LL  Tel  44 (0) 1728 621 631, Fax  44 (0) 1728 621 179
web: http://www.castle-technology.co.uk or http://www.castlet.demon.co.uk
Steps used to make things

1. rm -rf /usr
2. complete re-install from rpms to get clean /usr
3. mkdir /usr/arm_code, /usr/arm_code/binutils,, /usr/arm_code/egcs
4. install and patch binutils-2.9.1.0.15, egcs1.1b, linux-2.1.126 into
/usr/src
5. within /usr/src/linux:
	create include/linux/autoconf.h  empty file, but needed
	make menuconfig, and configure linux tree
	make symlinks  to set up various symbolic links
6. within /usr/src/arm_code/binutils do ../../binu*/configure arm-linux
--prefix=/usr
   edit bfd/config.h to comment out the definition of SETITIMER, or else
gprof/hertz.c will get upset
7. make
8. make install.. to link the made binutils to /usr

9. within /usr/src/arm_code/egcs:
	mkdir include
	cd include
	ln -s /usr/src/linux/include/asm asm
        ln -s /usr/src/linux/include/linux linux
	cd ..
	../../binu*/configure arm-linux --prefix=/usr

10. at this point it all blows up.. when the configure routine is
testing gcc, with its dumb conftest.c file, it wont even compile,
complaining that it cannot inderstand /usr/lib/crt0.o.. wrong format.
at this point I force re-installed the RPMs.. gcc works. I then make install
the binutils, hey presto gcc fails again.. where does this crt0.o file come
from?.. obviously it needs to be elf format (???) instead of aout.

11. hope that glibc has relevant bit, so.. do above for glibc-2.0.120..... this
fails requiring later make and gcc (I have 3.74 and 2.7.2.2)

12. so do above with make-3.77. It configures OK but complains when it gets
to arscan.c .. this needs ar.h which is missing...

13. with old compiler present, do above with egcs1.1b. this configures. go
into /usr/src/arm_code/egcs/gcc and do make LANGUAGES="c". 
/usr/src/eg*/gcc/config.in had gained a 'TOP' at line120. (WHY??? it wasnt
there at the start).. edit this out, and also in
/usr/src/arm_code/egcs/gcc/auto-conf.h line120 for safe measure. restart the
make... runs through to give complete xgcc. then make install LANGUAGES="c"
command fails with cpp...

14. so try xgcc on conftest.. fails with both old binutils and new as
follows:
ar*/eg*/gcc/xgcc ./conftest.c
/usr/arm-linux/bin/ld: cannot open crt1.o: No such file or directory
collect2: ld returned 1 exit status

note.. not crt0.o now.. but crt1.o  where do I get this?????

---

From: Philip Blundell <[email-masked]>
Date: Wed, 18 Nov 1998 10:37:27 +0100

Hi John,

>6. within /usr/src/arm_code/binutils do ../../binu*/configure arm-linux

I think this is your main problem.  If you install the ELF binutils in /usr 
you can't go on using your old gcc and libraries to build a.out executables. 
You probably want to configure binutils and egcs for cross-compiling at first 
(ie use ".../configure arm-linuxaout --target=arm-linux --prefix=/usr" or 
something like that).

>       ln -s /usr/src/linux/include/linux linux

This isn't correct.  You should put these in /usr/arm-linux/include, not in 
your build directory.

> LANGUAGES="c".  /usr/src/eg*/gcc/config.in had gained a 'TOP' at
> line120. (WHY??? it wasnt 

My guess would be that you have an old version of autoheader installed.

>note.. not crt0.o now.. but crt1.o  where do I get this?????

crt1.o is provided by glibc.  But you don't need that for kernel building. 

p.

unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Chris Sawer <[email-masked]>
Date: Wed, 18 Nov 1998 21:53:39 +0000

In message <[email-masked]>
          John Ballance <[email-masked]> wrote:

<snip>

> command fails with cpp...

No idea if this'll help, but anyway...

I couldn't make install LANGUAGES=c on egcs 1.1b as makeinfo didn't like some
of the files. I downloaded and compiled the latest version, but it still
complained so I commented out the appropriate lines in the Makefile and it
seemed to work (still won't compile glibc, tho' - see my other post).

Chris

-- 
         Chris Sawer - Worthing, Sussex, England    ICQ: 15010147
    E-Mail: [email-masked]    PGP public key available on request
http://members.xoom.com/chrissawer/  <-- ArmLinux Binaries, Hints and Tips
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]

---

From: Nicolas Pitre <[email-masked]>
Date: Wed, 18 Nov 1998 20:11:46 -0500 (EST)

I have the following code:

#define proc_idle()                             \
        do {                                    \
          unsigned long tmp;                    \
        __asm__ __volatile__(                   \
"       mcr     p15, 0, %0, c15, c2, 2\n"       \
"       ldr     %0, [%1]\n"                     \
"       mcr     p15, 0, %0, c15, c8, 2\n"       \
"       mcr     p15, 0, %0, c15, c1, 2\n"       \
        : : "r" (tmp), "r" (&ICIP));            \
        } while (0)

/*
 * The idle loop on an arm..
 */
asmlinkage int sys_idle(void)
{
        if (current->pid != 0)
                return -EPERM;

        /* endless idle loop with no priority at all */
        current->counter = -100;
        for (;;) {
                if (!hlt_counter && !need_resched)
                        proc_idle ();
                schedule();
        }
}

In the above, the compiler is generating funny things for the 
"if (!hlt_counter && !need_resched)" line.  It gets translated to this:

        .align  0
        .global _sys_idle
_sys_idle:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 1, current_function_anonymous_args = 0
        mov     ip, sp
        stmfd   sp!, {r4, r5, r6, fp, ip, lr, pc}
        ldr     r3, L426
        ldr     r1, [r3, #0]
        ldr     r2, [r1, #108]
        sub     fp, ip, #4
        cmp     r2, #0
        beq     L415
        mvn     r0, #0
        ldmea   fp, {r4, r5, r6, fp, sp, pc}
L427:
        .align  0
L426:
        .word   _current_set
L415:
        mvn     r3, #99
        str     r3, [r1, #4]
        ldr     r6, L428
        ldr     r5, L428+4
L416:
        ldr     r3, [r6, #0]
        cmp     r3, #0
        bne     L419
        ldr     r3, [r5, #0]
        cmp     r3, #0
***** wrong code start here *****
        moveq   ip, #-100663296
        addeq   ip, ip, #327680
       mcr     p15, 0, r4, c15, c2, 2
       ldr     r4, [ip]
       mcr     p15, 0, r4, c15, c8, 2
       mcr     p15, 0, r4, c15, c1, 2
***** wrong code stops here *****

L419:
        bl      _schedule
        b       L416
L429:
        .align  0
L428:
        .word   _hlt_counter
        .word   _need_resched

In the above, even if need_resched != 0, the macro proc_idle() is executed
even if it shouldn't but with its input value (in ip) not initialized.
Since ip is a pointer, it leads to funny things...

I tried gcc-2.7.2.2 and egcs-1.1b with Philip's patches applied and both
compilers give the same assembly.  The usual kernel compile flags were
passed to the compiler.

What could be wrong?  The C constructions seems OK to me.  Aren't they?

Thanks!

Nicolas Pitre, B. ing.
[email-masked]

---

From: Philip Blundell <[email-masked]>
Date: Thu, 19 Nov 1998 09:18:03 +0100

>compilers give the same assembly.  The usual kernel compile flags were

Try the latest egcs 1.1.1 prerelease; I think this bug is fixed there.  

Basically what's happening is that the backend is trying to conditionally 
execute the "if" rather than branching around it, but because it's an inline 
asm it doesn't actually have any way to add the right codes.

Compiling with -O1 rather than -O2 will probably make this go away as well.

p.

---

From: Russell King - ARM Linux Admin <[email-masked]>
Date: Thu, 19 Nov 1998 23:01:41 +0000 (GMT)

>         : : "r" (tmp), "r" (&ICIP));            \

You want:

 "       mcr%?     p15, 0, %0, c15, c2, 2\n"       \
 "       ldr%?     %0, [%1]\n"                     \
 "       mcr%?     p15, 0, %0, c15, c8, 2\n"       \
 "       mcr%?     p15, 0, %0, c15, c1, 2\n"       \

%? adds in the condition codes.  The other solution would be to tell
GCC that the asm corrupts "cc".

> What could be wrong?  The C constructions seems OK to me.  Aren't they?

Yep, C's ok, compilers ok.  Asm is not correct however.
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |        Russell King       [email-masked]      --- ---
  | | | |  http://www.arm.linux.org.uk/~rmk/armlinux.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |
unsubscribe: body of `unsubscribe linux-arm' to [email-masked]