| To: | wuzhangjin@gmail.com |
|---|---|
| Subject: | Re: MIPS/Linux assembly issue |
| From: | adnan iqbal <adnan.iqbal@seecs.edu.pk> |
| Date: | Tue, 25 May 2010 10:33:34 +0500 |
| Cc: | linux-mips@linux-mips.org |
| In-reply-to: | <1274445001.9403.5.camel@localhost> |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| References: | <AANLkTikrUGzUykZJwoK3Jq9mEJa6l35jo5DXHae3vbIG@mail.gmail.com> <1274445001.9403.5.camel@localhost> |
| Sender: | linux-mips-bounce@linux-mips.org |
|
Dear Wu and Arnaud Many many thanx for your help. Because of your help, i have been able to do the following. 1. Write an assembly program for octeon which starts with a routine __start. 2. Extend this program such that it calls a function written in C which resides in another file compiled separately but linked statically to make one executable. Essentialy i use following sequence of commands for compilation and linking $as hello2.s -o hello2.o $gcc -c c_func.c -o c_func.o $gcc -O2 -g -Wall -Wmissing-prototypes -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-declarations -Wno-format-zero-length -fno-strict-aliasing -Wno-long-long -Wno-pointer-sign -Wdeclaration-after-statement -fno-stack-protector -static -Wl,-defsym,valt_load_address=0x40000000 -nodefaultlibs -nostartfiles -u start -Wl,-T,valt_load_address_mips64_linux.lds -o hello2 hello2.o c_func.o -lgcc All this is great but i need to do a bit more. I have to write a c program which has entry point __start written in inline-assembly and makes use of c functions (and global data ) defined in same file. I wrote a program for this purpose and tried to compile and link it using different methods but it did not work. The program compiles but gives a segmentation fault. Below is the code for the program. The code of hello_in_c.c ----------------------------------- int f1() { //called return 0; } asm( ".text\n" ".globl __start\n" ".ent __start \n" "__start: \n" "\t.set noreorder \n" "\t.cpload $gp\n" "\t.set reorder\n" "\tli $4, 1\n" "\tla $5, stradr \n" "\tlw $6, strlen\n" "\tli $2, 4004\n" "\tsyscall\n" "\tjal f1\n" "\tmove $4, $0\n" "\tli $2, 4001\n" "\tsyscall\n" ".end __start\n" "\t.rdata\n" "stradr: .asciiz \"hello, world!\\n\"\n" "strlen: .word . - stradr" ); ----------------------------------------------------------------- thank you for your previous help and hope to get more from you. Regards Adnan On Fri, May 21, 2010 at 5:30 PM, Wu Zhangjin <wuzhangjin@gmail.com> wrote: Hi, |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE: Kernel unaligned access, Maciej W. Rozycki |
|---|---|
| Next by Date: | Re: Cross compiling MIPS kernel under x86, Ralf Baechle |
| Previous by Thread: | Re: MIPS/Linux assembly issue, Wu Zhangjin |
| Next by Thread: | Re: bkl: Pushdowns for sound/oss ?, Ralf Baechle |
| Indexes: | [Date] [Thread] [Top] [All Lists] |