LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2005, 01:45 PM   #1
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Rep: Reputation: 16
Unhappy IMMIDIATE : making an obj. file


Hi guys!

i immidiatly need help on this simple matter. Actually i have a file

file1.c and file2.s . Some of the functions in file1.c are written in assembly

language and are thus placed in file2.s . NOW, wat optiopn of 'cc' will give me

a single object file such that all the code is linked together . Actualli i m doing

this for the first time:


Like


cc -o file1.c file2.s


gives error like : " file not recognized: Invalid request code"


Any, information wud be appriciated. Any body !
 
Old 04-24-2005, 01:59 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
cc -o file3 file1.c file2.s
 
Old 04-24-2005, 02:00 PM   #3
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
ok let me try this !
 
Old 04-24-2005, 02:03 PM   #4
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
Sorry buddy ,This give this error:

cc: file1: No such file or directory
 
Old 04-24-2005, 02:07 PM   #5
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
i actually issued this command:

cc -o file1 file1.c file2.s
 
Old 04-24-2005, 02:38 PM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
And ?
 
Old 04-24-2005, 02:47 PM   #7
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
ok if any body knows something about the assembly syntax : can one plz tell hoe to start an assembly code:

is this the right way:

code starts:

#include <::::::::>

_firstasmfunc:
move a,c
::::
::::
::::
:::
_secondasmfunc
lstw b,c
bnz
:::
:::

etc. etc.

code ends

i need help , as i dont have any documentation or any references. If u know any site address dealing these
syntax related issues plz tell.........
 
Old 04-24-2005, 02:51 PM   #8
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
i believe my problem is related to the assembly issue . As the loader is not recognizing the .s file and giving the exit status 1.
and my .s file viz file2.s is written in the way described above
 
Old 04-24-2005, 03:21 PM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
What assembler, loader, O/S, CPU are you using ?
What are the error messages ?
What are you trying to achieve ?
Who wrote the assembler code ?
Why do you need assembly code ?
Why are you hiding parts of your code ?
This doesn't look right:
Code:
#include <::::::::>
 
Old 04-24-2005, 03:32 PM   #10
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
-i m using powePc 603

-i m using Gnu CC compiler

-error message is :
"
file not recognized: Invalid request code
collect2: ld returned 1 exit status"

-i need an assembly code thats a long story ( n hence cant tell u now)

-by #include<::::> i meant to say files like
#include <asm.h> or other file.

- all i m trying to achive is a single object file of the two files.

i m sure my c code is well in file1.c , there r some funstion calls from this file to the .s file.
The code written in .s file is


code starts:

#include <asm.h>
cmp:
_cmp:
stwu 1,-32(1)
stw 31,28(1)
mr 31,1
cmpw 0,3,4
bc 12,2,.true
li 5,0
b .exit

.true:
li 5,1
b .exit
.exit:
lwz 11,0(1)
lwz 31,-4(11)
mr 1,11
blr


code ends:
 
Old 04-24-2005, 03:37 PM   #11
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
so this is how my file2.s luks. All i wanna achive is that after linking those two files will generate a single file

ccppc with -o option is giving the error as mentioned above
 
Old 04-24-2005, 06:49 PM   #12
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Original Poster
Rep: Reputation: 16
hey for all those who wanna learn some assembly! i found a link that gives sum primitive example : atleast for ppc for 32 1nd 64 bits:
http://www-106.ibm.com/developerwork...nxw09=PowPC#h8
 
Old 04-25-2005, 01:38 AM   #13
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
-by #include<::::> i meant to say files like
#include <asm.h> or other file.
The previous directive is a C preprocessing directive, but not ASM.
A ".h" file is usually containing C statement, and can't be understood by an assembler.
Including in asm is usually done with: ".include filename"
Quote:
- all i m trying to achive is a single object file of the two files.
You cannot build an object (.o) from two files, you can build a binary executable or a library.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What's /usr/src/linux-obj for? rose_bud4201 Linux - General 2 07-03-2005 06:00 PM
How can i convert .obj to jpeg format in Tgif?? realxixi Linux - Software 0 11-03-2004 10:34 PM
Making VSAM file from a flat file in AIX Raghothaman AIX 2 08-25-2004 04:55 PM
looking for a .obj files viewer aizkorri Linux - Software 0 09-19-2003 05:23 AM
Using Shared Obj implicitly ugenn Programming 0 04-15-2002 09:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration