LinuxQuestions.org
Visit Jeremy's Blog.
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 08-02-2004, 07:29 PM   #1
Dagda99
LQ Newbie
 
Registered: Jul 2004
Posts: 19

Rep: Reputation: 0
ENTRY in .S file results in parse error


In a .S file I'm working with, (snipping some code from oprofile.sourceforge.net), it reads
Code:
ENTRY(op_nmi)
     pushl %eax
When I compile this using gcc 3.3.4, I get:
test_nmi.S:41: error: parse error before "pushl"

I've narrowed it down to that pushl, and when I put something else, like a label, in between:
Code:
ENTRY(op_nmi)
temp:
     pushl %eax
gcc gives me
test_nmi.S:41: error: parse error before "temp"

A few other things I've tried:
ENTRY (op_nmi)
temp:

error: parse error before "temp"

ENTRY op_nmi
temp:

error: parse error before op_nmi

Is "ENTRY" not allowed in a loadable module? This file itself isn't a loadable module, but is included in one. And if not, what can I replace it with?
(I'm a newb, so any help would be appreciated)
I've been working at isolating this and seeing if any syntax changes will fix it all day, so any thoughts, ideas, links, or instructions would be a huge help
Oh, and I'm running 2.4.26, Slack 10.0 on a Dual P3 Xeon running a uniprocessor kernel.
Thanks,
Dagda
 
Old 08-02-2004, 08:08 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
have u included linux/linkage.h where ENTRY is defined?
 
Old 08-02-2004, 08:11 PM   #3
Dagda99
LQ Newbie
 
Registered: Jul 2004
Posts: 19

Original Poster
Rep: Reputation: 0
Yes. My includes are:

#include <linux/sys.h>
#include <linux/linkage.h>
#include <segment.h>
#include <asm/smp.h>
 
Old 08-02-2004, 08:16 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
i'm just guessing here, maybe u have to assemble it with 'as' instead of using gcc?
 
Old 08-02-2004, 08:18 PM   #5
slidesystems
LQ Newbie
 
Registered: Aug 2004
Location: nigeria
Distribution: redhat
Posts: 6

Rep: Reputation: 0
hello,
plz i am trying to configure bandwith management and squid on linux machine. i dont want browsing bandwith to chop into call bandwith. need help on how to shape bandwith between the two and how to get squid well configured.
regards.

kaazzman@yahoo.com
 
Old 08-02-2004, 08:19 PM   #6
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
oh and i just noticed this:
Code:
#ifdef __ASSEMBLY__

#define ALIGN __ALIGN
#define ALIGN_STR __ALIGN_STR

#define ENTRY(name) \
  .globl SYMBOL_NAME(name); \
  ALIGN; \
  SYMBOL_NAME_LABEL(name)

#endif
if __ASSEMBLY__ isn't defined that won't be included. i donno if u have to define it yourself or if some other header defines it tho..
 
Old 08-02-2004, 08:21 PM   #7
Dagda99
LQ Newbie
 
Registered: Jul 2004
Posts: 19

Original Poster
Rep: Reputation: 0
I have __ASSEMBLY__ defined
Code:
#ifndef __ASSEMBLY__
#define __ASSEMBLY__
#endif
And what I'm doing is compiling a .c file that includes this one, test_nmi.S, and so am using gcc on the .c file, which then gives errors for this file.
I'll try 'as' on the .S file by itself though.
Thanks,
Dagda
 
Old 08-02-2004, 11:57 PM   #8
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
slidesystems:

Your post does not belong here. You posted the same message in several unrelated threads across LQ. Please do not post duplicate messages in the future.

http://www.linuxquestions.org/rules.php

The correct post is the one you put in Networking:

http://www.linuxquestions.org/questi...hreadid=212694
 
Old 08-03-2004, 12:49 PM   #9
Dagda99
LQ Newbie
 
Registered: Jul 2004
Posts: 19

Original Poster
Rep: Reputation: 0
I tried using as; oddly enough I get a completely different set of error messages, most from the same cause, but I assume that is because this program was made to be compiled in gcc (I think?)
The entire source is:
Code:
#ifndef __ASSEMBLY__
#define __ASSEMBLY__  /* for some 2.2 kernel */
#endif
#include <linux/sys.h>
#include <linux/linkage.h>
#include <asm/segment.h>
#define ASSEMBLY
#include <asm/smp.h>

#define RESTORE_ALL	\
	popl %ebx;	\
	popl %ecx;	\
	popl %edx;	\
	popl %esi;	\
	popl %edi;	\
	popl %ebp;	\
	popl %eax;	\
1:	popl %ds;	\
2:	popl %es;	\
	addl $4,%esp;	\
3:	iret;		\
.section .fixup,"ax";	\
4:	movl $0,(%esp);	\
	jmp 1;		\
5:	movl $0,(%esp);	\
	jmp 2;		\
6:	pushl %ss;	\
	popl %ds;	\
	pushl %ss;	\
	popl %es;	\
	/*pushl $11;	\
	*/call my_sys_exit;\
.previous;		\
.section __ex_table,"a";\
	.align 4;	\
	.long 1,4;	\
	.long 2,5;	\
	.long 3,6;	\
.previous

ENTRY(op_nmi)
	pushl %eax
	SAVE_ALL
	movl %esp,%edx
	pushl %edx
	call op_do_nmi
	addl $4,%esp
	RESTORE_ALL
And the errors with
as test_nmi.S
are:
Code:
oprofile_nmi.S: Assembler messages:
oprofile_nmi.S:11: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:12: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:13: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:14: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:15: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:16: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:17: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:18: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:19: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:20: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:21: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:22: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:23: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:24: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:25: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:26: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:27: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:28: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:29: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:30: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:32: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:33: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:34: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:35: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:36: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:37: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:38: Error: junk at end of line, first unrecognized character is `\'
oprofile_nmi.S:41: Error: invalid character '(' in mnemonic
oprofile_nmi.S:43: Error: invalid character '_' in mnemonic
oprofile_nmi.S:48: Error: invalid character '_' in mnemonic
Removing all the slashes that result in errors and doing:
as test_nmi.S
yields:
Code:
oprofile_nmi.S:41: Error: invalid character '(' in mnemonic
oprofile_nmi.S:43: Error: invalid character '_' in mnemonic
oprofile_nmi.S:48: Error: invalid character '_' in mnemonic
Going back to the original (with slashes) and executing:
gcc test_nmi.S
yields:
Code:
oprofile_nmi.S: Assembler messages:
oprofile_nmi.S:43: Error: invalid character '_' in mnemonic


Sorry for the length of that, and I'm not expecting anyone to tell me exactly what to do, I just wanted to have it clear;
Here's what I think, correct me if I'm wrong:
Gcc aparrently can work out the slashes by itself, and I like that it returns less errors. It seems to accept the ENTRY(op_nmi) line; and only doesn't like the '_' in names of subroutines. So, if I were to change the names to RESTOREALL, removing the '_'; and add back the original SAVE_ALL (I removed it from the file because the function was previously defined elsewhere, probably a bad idea), and change its name and the reference to it to SAVEALL, it should (?) compile correctly?
I'll give that a shot, if anyone sees any errors or has any suggestions, I'm all ears.

And Thanks infamous41md for looking both at this and my other problem!
-Dagda
 
Old 08-03-2004, 05:59 PM   #10
Dagda99
LQ Newbie
 
Registered: Jul 2004
Posts: 19

Original Poster
Rep: Reputation: 0
OK, so doing that all seemed to lead down fruitless paths, so I'm trying something else - snipping all the code I need and putting it into one file.

Next problem (I'm dealing with 1 .c file and 1 .S file)

First, I have a function in a .S file, op_nmi:
(by the way, if this isn't how you use "ENTRY", please let me know; I'm assembler illiterate and so am copy-pasting-tryingToUnderstand code)

ENTRY(op_nmi)
call op_do_nmi


And I have a function in a .c file called op_do_nmi
asmlinkage void op_do_nmi (struct pt_regs * regs) //I took this from some source I’m using to put this together
{
}

And finally I have a function in that .c file:
#define someFunction(addr)
…code here…
#define someOtherFunction\
someFunction(&op_nmi)

In the .c file, I need to reference the function/pointer (op_nmi) that is in the .S file. And in the .S file, I need to reference the function in the .c file.
And of course, I get errors saying that the functions each is looking for in the other file is undefined.

I believe this is a simple linking problem, but have no idea how to fix it.
My makefile (this is just a part) has:
all: Driver.o
Driver.o: SimAssembly.o SimDriver.o

and the flags on the compiler are (these are seen on the console):
cc -D__KERNEL__ -DMODULE -Wall -O2 -c -o for the SimDriver.c file
and
cc -c -o for the SimAssembly.S file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 02:29 AM
C source file Parse error before 38 exvor Programming 5 09-19-2005 03:10 PM
Perl file conversion results in a truncated file kshaffer Programming 0 01-31-2005 03:31 PM
Parse Error in G++ ashwinipahuja Programming 1 04-29-2004 02:47 AM
Parse error returned when compiling a source file with Kdevelop spilios Programming 1 09-09-2003 07:00 AM

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

All times are GMT -5. The time now is 06:17 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration