public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Smpeg MMX asm compilation (problem)
@ 2006-08-20 19:59 Matthew Bentley
  2006-08-21  1:38 ` Daniel Jacobowitz
  0 siblings, 1 reply; 17+ messages in thread
From: Matthew Bentley @ 2006-08-20 19:59 UTC (permalink / raw)
  To: binutils

Hi Guys,
I'm working on SMPEG, putting a bunch of optimizations into the
code- can't get any of the assembler code to compile tho'-
I'm building under msys, mingw. Please look at the following code and let me
know what I'm doing wrong:
http://cvs.icculus.org/*checkout*/cvs/smpeg/video/mmxflags_asm.S?rev=1.6

"#if defined(i386) && defined(USE_MMX)

.text
 .align 4
.globl cpu_flags
 .type  cpu_flags,@function
cpu_flags:
        pushfl
        popl %eax

        movl %eax,%ecx

        xorl $0x040000,%eax
        pushl %eax

        popfl
        pushfl

        popl %eax
        xorl %ecx,%eax
        jz cpu_flags.L1   # Processor is 386

        pushl %ecx
        popfl

        movl %ecx,%eax
        xorl $0x200000,%eax

        pushl %eax
        popfl
        pushfl

        popl %eax
        xorl %ecx,%eax
        je cpu_flags.L1

        pushl %ebx

        movl $1,%eax
        cpuid
        movl %edx,%eax

        popl %ebx

cpu_flags.L1:
        ret
.Lfe1:
 .size  cpu_flags,.Lfe1-cpu_flags

#endif /* i386 && USE_MMX */

#ifdef __ELF__
.section .note.GNU-stack,"",%progbits
#endif
"

Here's the error I get back:
video/mmxflags_asm.S: Assembler messages:
video/mmxflags_asm.S:7: Warning: .type pseudo-op used outside of .def/.endef
ign
ored.
video/mmxflags_asm.S:7: Error: junk at end of line, first unrecognized
character
 is `c'
video/mmxflags_asm.S:49: Warning: .size pseudo-op used outside of
.def/.endef ig
nored.
video/mmxflags_asm.S:49: Error: junk at end of line, first unrecognized
characte
r is `c'
make: *** [mmxflags_asm.lo] Error 1"

Now I'm pretty new to make etc- but I've hunted the internet up and down,
and the msot informative page I could find was this:
http://www.gentoo.org/proj/en/hardened/pic-fix-guide.xml :and it doesn't
tell me how to fix the errors in the more recent code, only the old stuff
(which, by the way, won't compile either):
any help you could give would be much appreciated-
Cheers,
M@



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-20 19:59 Smpeg MMX asm compilation (problem) Matthew Bentley
@ 2006-08-21  1:38 ` Daniel Jacobowitz
  2006-08-21  1:54   ` Matthew Bentley
  0 siblings, 1 reply; 17+ messages in thread
From: Daniel Jacobowitz @ 2006-08-21  1:38 UTC (permalink / raw)
  To: Matthew Bentley; +Cc: binutils

On Sun, Aug 20, 2006 at 12:30:55PM +1200, Matthew Bentley wrote:
> I'm building under msys, mingw.

> .text
>  .align 4
> .globl cpu_flags
>  .type  cpu_flags,@function

This is ELF assembly.  It won't work on mingw32, which uses COFF/PE.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-21  1:38 ` Daniel Jacobowitz
@ 2006-08-21  1:54   ` Matthew Bentley
  2006-08-21 15:25     ` Daniel Jacobowitz
  2006-08-21 22:52     ` Pedro Alves
  0 siblings, 2 replies; 17+ messages in thread
From: Matthew Bentley @ 2006-08-21  1:54 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: binutils

Thanks Daniel- I've been trying to figure that out for ages.
Any way at all to compile ELF asm in windows?
Or an easy way to convert the code to COFF?
Thanks,
Mat

----- Original Message ----- 
From: "Daniel Jacobowitz" <drow@false.org>
To: "Matthew Bentley" <moc.pophot@hotpop.com>
Cc: <binutils@sourceware.org>
Sent: Sunday, August 20, 2006 1:45 PM
Subject: Re: Smpeg MMX asm compilation (problem)


> On Sun, Aug 20, 2006 at 12:30:55PM +1200, Matthew Bentley wrote:
> > I'm building under msys, mingw.
> 
> > .text
> >  .align 4
> > .globl cpu_flags
> >  .type  cpu_flags,@function
> 
> This is ELF assembly.  It won't work on mingw32, which uses COFF/PE.
> 
> -- 
> Daniel Jacobowitz
> CodeSourcery
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-21  1:54   ` Matthew Bentley
@ 2006-08-21 15:25     ` Daniel Jacobowitz
  2006-08-21 22:52     ` Pedro Alves
  1 sibling, 0 replies; 17+ messages in thread
From: Daniel Jacobowitz @ 2006-08-21 15:25 UTC (permalink / raw)
  To: Matthew Bentley; +Cc: binutils

On Sun, Aug 20, 2006 at 04:08:33PM +1200, Matthew Bentley wrote:
> Thanks Daniel- I've been trying to figure that out for ages.
> Any way at all to compile ELF asm in windows?
> Or an easy way to convert the code to COFF?

Not that I know of.  You'd have to look at some GCC sample Windows
output and do it by hand.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-21  1:54   ` Matthew Bentley
  2006-08-21 15:25     ` Daniel Jacobowitz
@ 2006-08-21 22:52     ` Pedro Alves
  2006-08-22  1:10       ` Soul Studios
  1 sibling, 1 reply; 17+ messages in thread
From: Pedro Alves @ 2006-08-21 22:52 UTC (permalink / raw)
  To: Matthew Bentley; +Cc: Daniel Jacobowitz, binutils

Matthew Bentley wrote:
>>On Sun, Aug 20, 2006 at 12:30:55PM +1200, Matthew Bentley wrote:
>>
>>>I'm building under msys, mingw.
>>
>>>.text
>>> .align 4
>>>.globl cpu_flags
>>> .type  cpu_flags,@function
>>
>>This is ELF assembly.  It won't work on mingw32, which uses COFF/PE.
>>
 > Thanks Daniel- I've been trying to figure that out for ages.
 > Any way at all to compile ELF asm in windows?
 > Or an easy way to convert the code to COFF?

instead of:
.type cpu_flags,@function
you write:
.def cpu_flags; .scl 2; .type 32; .endef

You can leave ".size" out.

You would be better off writting defines/macros for this.

Simplified example, from code found in some places in gnu sources:

#ifdef __ELF__
# define TYPE(x) .type x,@function
# define SIZE(x) .size x, . - x
#else
# define TYPE(x) .def x; .scl 2; .type 32; .endef
# define SIZE(x)
#endif

Cheers,
Pedro Alves

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-21 22:52     ` Pedro Alves
@ 2006-08-22  1:10       ` Soul Studios
  2006-08-22  3:05         ` Pedro Alves
  2006-08-22  3:42         ` Brian Dessent
  0 siblings, 2 replies; 17+ messages in thread
From: Soul Studios @ 2006-08-22  1:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Matthew Bentley, Daniel Jacobowitz, binutils

Thanks all-
how do you call macros in GNU as?- I've tried copying examples from the 
net but gas complains about the syntax.
Or do I need to be running the file through GCC instead to use the 
#define's?

A few more questions:
from mmxflags_asm.S:
What is .Lfe1?
Is it a register, a function call?

Is there a table somewhere for all the different "@" types and their 
respective int's (ie @object, @function, etc)?



And I'm now looking at 
http://cvs.icculus.org/*checkout*/cvs/smpeg/video/mmxidct_asm.S?rev=1.7
which's even more complicated. How do I go about converting something 
like this?

I am absolutely astounded at the lack of documentation on this stuff, on 
the web- usually when I'm researching something I can google it in about 
15 minutes, even when it's relatively obscure-
but pages on differences between COFF/PE & ELF syntax are naught, and 
COFF pages seem scarce- any useful URL's you have would be... useful?
Thanks again,
M@



> Simplified example, from code found in some places in gnu sources:
> 
> #ifdef __ELF__
> # define TYPE(x) .type x,@function
> # define SIZE(x) .size x, . - x
> #else
> # define TYPE(x) .def x; .scl 2; .type 32; .endef
> # define SIZE(x)
> #endif
> 
> Cheers,
> Pedro Alves
> 
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  1:10       ` Soul Studios
@ 2006-08-22  3:05         ` Pedro Alves
  2006-08-22  3:42         ` Brian Dessent
  1 sibling, 0 replies; 17+ messages in thread
From: Pedro Alves @ 2006-08-22  3:05 UTC (permalink / raw)
  To: Soul Studios; +Cc: binutils

Soul Studios wrote:
> Thanks all-
> how do you call macros in GNU as?- I've tried copying examples from the 
> net but gas complains about the syntax.
> Or do I need to be running the file through GCC instead to use the 
> #define's?
> 

Macros and defines are different things. I may have lead you
to believe they are the same. Macros are handled by gas, but
the #defines need to be ran through by a preprocessor.
Since the file you are porting already has some #defines in it,
the build system that project is using must be already taking care
of that.
But yes, the easiest way is to call the gcc driver on it. If the
file extension is ".S" (uppercase), it knows it has to call
the preprocessor, and then call the assembler.


> A few more questions:
> from mmxflags_asm.S:
> What is .Lfe1?
> Is it a register, a function call?

A local label. If I remember correctly, i386 mingw/cygwin
uses "L" as local label prefix, while elf usually uses ".L" prefix.
I suggest using a define for this too:

#ifdef __ELF__
# define LSYM(S) . ## S
#else
# define LSYM(S) S
#endif

Cheers,
Pedro Alves


> 
> Is there a table somewhere for all the different "@" types and their 
> respective int's (ie @object, @function, etc)?
> 
> 
> 
> And I'm now looking at 
> http://cvs.icculus.org/*checkout*/cvs/smpeg/video/mmxidct_asm.S?rev=1.7
> which's even more complicated. How do I go about converting something 
> like this?
> 
> I am absolutely astounded at the lack of documentation on this stuff, on 
> the web- usually when I'm researching something I can google it in about 
> 15 minutes, even when it's relatively obscure-
> but pages on differences between COFF/PE & ELF syntax are naught, and 
> COFF pages seem scarce- any useful URL's you have would be... useful?
> Thanks again,
> M@
> 
> 
> 
>> Simplified example, from code found in some places in gnu sources:
>>
>> #ifdef __ELF__
>> # define TYPE(x) .type x,@function
>> # define SIZE(x) .size x, . - x
>> #else
>> # define TYPE(x) .def x; .scl 2; .type 32; .endef
>> # define SIZE(x)
>> #endif
>>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  1:10       ` Soul Studios
  2006-08-22  3:05         ` Pedro Alves
@ 2006-08-22  3:42         ` Brian Dessent
  2006-08-22  5:47           ` Pedro Alves
  2006-08-22  6:44           ` Matt Bentley
  1 sibling, 2 replies; 17+ messages in thread
From: Brian Dessent @ 2006-08-22  3:42 UTC (permalink / raw)
  To: Soul Studios; +Cc: Pedro Alves, Matthew Bentley, Daniel Jacobowitz, binutils

Soul Studios wrote:

> how do you call macros in GNU as?- I've tried copying examples from the
> net but gas complains about the syntax.
> Or do I need to be running the file through GCC instead to use the
> #define's?

Read section 3.1 of the manual.

> A few more questions:
> from mmxflags_asm.S:
> What is .Lfe1?
> Is it a register, a function call?

Neither.  It's a label, because it ends in a colon.  It is just a
temporary label to use in computing the length of the cpu_flags function
in the .size expression in the next line.  The fact that is is named 'L'
+ some hex number implies that it is just a dummy label that was
probably automatically generated.

> Is there a table somewhere for all the different "@" types and their
> respective int's (ie @object, @function, etc)?

Look at the documentation for .type in the manual, in section 7.

> And I'm now looking at
> http://cvs.icculus.org/*checkout*/cvs/smpeg/video/mmxidct_asm.S?rev=1.7
> which's even more complicated. How do I go about converting something
> like this?

That's pretty ugly.  There's lots of stuff in there that's ELF
specific.  For example, on windows, all code is PIC and there is no
GOT.  So that code will take more than a few changes to be portable to
anything but ELF.

Have you considered that stuff like MMX IDCT routines for video decoding
is pretty much a solved problem?  For example, take a look at how
libavcodec implments this.  They use gcc's inline __asm__ () statements
(through defines in mmx.h) and don't bother themselves with platform
specific details that can be handled by the compiler and/or assembler. 
This code compiles and runs the same on both linux and mingw/windows.

http://svn.sourceforge.net/viewvc/ffdshow/trunk/src/ffmpeg/libavcodec/i386/idct_mmx.c?revision=2471&view=markup
http://svn.sourceforge.net/viewvc/ffdshow/trunk/src/ffmpeg/libavcodec/i386/mmx.h?revision=2484&view=markup
http://svn.sourceforge.net/viewvc/ffdshow/trunk/src/ffmpeg/libavcodec/i386/

> but pages on differences between COFF/PE & ELF syntax are naught, and
> COFF pages seem scarce- any useful URL's you have would be... useful?

Perhaps you need to read
http://sourceware.org/binutils/docs-2.17/as/index.html ?

Brian

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  3:42         ` Brian Dessent
@ 2006-08-22  5:47           ` Pedro Alves
  2006-08-22 12:11             ` Nick Clifton
                               ` (3 more replies)
  2006-08-22  6:44           ` Matt Bentley
  1 sibling, 4 replies; 17+ messages in thread
From: Pedro Alves @ 2006-08-22  5:47 UTC (permalink / raw)
  To: binutils; +Cc: Soul Studios, Matthew Bentley, Daniel Jacobowitz

Brian Dessent wrote:
> Soul Studios wrote:
> 

>> Is there a table somewhere for all the different "@" types and their
>> respective int's (ie @object, @function, etc)?
> 
> Look at the documentation for .type in the manual, in section 7.
> 

Would be nice if there was some info on DT_NON, DT_PTR, DT_FCN,
DT_ARY and N_BTSHFT there, or just plainly the numbers.

Who was never bitten once by not putting .type 32 (DT_FCN << N_BTSHFT)
on an assembly function that was then mistakingly dll exported
as DATA. I have. :)

Cheers,
Pedro Alves

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  3:42         ` Brian Dessent
  2006-08-22  5:47           ` Pedro Alves
@ 2006-08-22  6:44           ` Matt Bentley
  1 sibling, 0 replies; 17+ messages in thread
From: Matt Bentley @ 2006-08-22  6:44 UTC (permalink / raw)
  To: binutils

(whoops, used wrong email address, last time)
Thanks Brian - will look into all that - may even consider swapping over 
to libavcodec, at some point - but for the moment smpeg is easier and I 
don't have to write my own frame-timer routines, etc.
Thanks for the documentation, I've been trying to find something like 
that (perhaps my eyes were closed...).
:)
Will look and see whether I can port the inline routines into what I'm 
doing, and get back to you all-
Cheers-


>> how do you call macros in GNU as?- I've tried copying examples from the
>> net but gas complains about the syntax.
>> Or do I need to be running the file through GCC instead to use the
>> #define's?
> 
> Read section 3.1 of the manual.
> 
>> A few more questions:
>> from mmxflags_asm.S:
>> What is .Lfe1?
>> Is it a register, a function call?
> 
> Neither.  It's a label, because it ends in a colon.  It is just a
> temporary label to use in computing the length of the cpu_flags function
> in the .size expression in the next line.  The fact that is is named 'L'
> + some hex number implies that it is just a dummy label that was
> probably automatically generated.
> 
>> Is there a table somewhere for all the different "@" types and their
>> respective int's (ie @object, @function, etc)?
> 
> Look at the documentation for .type in the manual, in section 7.
> 
>> And I'm now looking at
>> http://cvs.icculus.org/*checkout*/cvs/smpeg/video/mmxidct_asm.S?rev=1.7
>> which's even more complicated. How do I go about converting something
>> like this?
> 
> That's pretty ugly.  There's lots of stuff in there that's ELF
> specific.  For example, on windows, all code is PIC and there is no
> GOT.  So that code will take more than a few changes to be portable to
> anything but ELF.
> 
> Have you considered that stuff like MMX IDCT routines for video decoding
> is pretty much a solved problem?  For example, take a look at how
> libavcodec implments this.  They use gcc's inline __asm__ () statements
> (through defines in mmx.h) and don't bother themselves with platform
> specific details that can be handled by the compiler and/or assembler. 
> This code compiles and runs the same on both linux and mingw/windows.
> 
> http://svn.sourceforge.net/viewvc/ffdshow/trunk/src/ffmpeg/libavcodec/i386/idct_mmx.c?revision=2471&view=markup
> http://svn.sourceforge.net/viewvc/ffdshow/trunk/src/ffmpeg/libavcodec/i386/mmx.h?revision=2484&view=markup
> http://svn.sourceforge.net/viewvc/ffdshow/trunk/src/ffmpeg/libavcodec/i386/
> 
>> but pages on differences between COFF/PE & ELF syntax are naught, and
>> COFF pages seem scarce- any useful URL's you have would be... useful?
> 
> Perhaps you need to read
> http://sourceware.org/binutils/docs-2.17/as/index.html ?
> 
> Brian
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  5:47           ` Pedro Alves
@ 2006-08-22 12:11             ` Nick Clifton
  2006-08-22 17:22               ` Soul Studios
  2006-08-23  1:53             ` Matt
                               ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Nick Clifton @ 2006-08-22 12:11 UTC (permalink / raw)
  To: Pedro Alves; +Cc: binutils, Soul Studios, Matthew Bentley, Daniel Jacobowitz

Hi Pedro,

>> Look at the documentation for .type in the manual, in section 7.

> Would be nice if there was some info on DT_NON, DT_PTR, DT_FCN,
> DT_ARY and N_BTSHFT there, or just plainly the numbers.

Documentation patches and updates are *always* welcome. :-)

Cheers
   Nick


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22 12:11             ` Nick Clifton
@ 2006-08-22 17:22               ` Soul Studios
  0 siblings, 0 replies; 17+ messages in thread
From: Soul Studios @ 2006-08-22 17:22 UTC (permalink / raw)
  Cc: binutils

> Documentation patches and updates are *always* welcome. :-)
> 
> Cheers
>   Nick
> 
> 

I think the problem is that the manuals aren't in a format that most 
people understand or can easily edit - asides from the HTML one's that is-
if it was a user-readable format that'd be different- personally I can't 
be bothered at all, even viewing them is a chore compared to something 
like XML or HTML- not to bitch mind you, I just find it puts me off 
trying, when I can't even view them in a text editor easily.
m@t

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  5:47           ` Pedro Alves
  2006-08-22 12:11             ` Nick Clifton
@ 2006-08-23  1:53             ` Matt
  2006-08-23 17:33               ` Nick Clifton
  2006-08-23  2:45             ` Matt
  2006-08-24  8:33             ` Matt
  3 siblings, 1 reply; 17+ messages in thread
From: Matt @ 2006-08-23  1:53 UTC (permalink / raw)
  To: binutils; +Cc: drow

Alright, I've managed to get both .S files to compile- however when I 
try to link them with a program using:
extern "C" {
extern unsigned int cpu_flags(void);
extern void IDCT_mmx(DCTBLOCK data);
}

The linker tool comes up with
./.libs/libsmpeg.a(parseblock.o): In function `Z8InitIDCTv':
e:/programming/smpeg/video/parseblock.cpp:117: undefined reference to 
`cpu_flags()'
./.libs/libsmpeg.a(parseblock.o): In function 
`Z15ParseReconBlockiP10vid_stream':
e:/programming/smpeg/video/parseblock.cpp:583: undefined reference to 
`IDCT_mmx(short*)'

They *are* getting assembled&linked- Why is this??
Here's the code for the mmxflags_asm.S, which should be enough for you 
folk to figure it out:
"
.text
	.align 2
.globl cpu_flags
	.def	cpu_flags;	.scl   2;      .type 32;	.endef
cpu_flags:
         pushfl
         popl %eax

         movl %eax,%edx

         xorl $0x040000,%eax
         pushl %eax

         popfl
         pushfl

         popl %eax
         xorl %ecx,%eax
         jz cpu_flags.L1   # Processor is 386

         pushl %ecx
         popfl

         movl %ecx,%eax
         xorl $0x200000,%eax

         pushl %eax
         popfl
         pushfl

         popl %eax
         xorl %ecx,%eax
         je cpu_flags.L1

         pushl %ebx

         movl $1,%eax
         cpuid
         movl %edx,%eax

         popl %ecx

cpu_flags.L1:
         ret

"

M@

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  5:47           ` Pedro Alves
  2006-08-22 12:11             ` Nick Clifton
  2006-08-23  1:53             ` Matt
@ 2006-08-23  2:45             ` Matt
  2006-08-23 17:49               ` Pedro Alves
  2006-08-24  8:33             ` Matt
  3 siblings, 1 reply; 17+ messages in thread
From: Matt @ 2006-08-23  2:45 UTC (permalink / raw)
  To: binutils; +Cc: Pedro Alves, Daniel Jacobowitz

Alright, I've managed to get both .S files to compile- however when I 
try to link them with a program using:
extern "C" {
extern unsigned int cpu_flags(void);
extern void IDCT_mmx(DCTBLOCK data);
}

The linker tool comes up with
./.libs/libsmpeg.a(parseblock.o): In function `Z8InitIDCTv':
e:/programming/smpeg/video/parseblock.cpp:117: undefined reference to 
`cpu_flags()'
./.libs/libsmpeg.a(parseblock.o): In function 
`Z15ParseReconBlockiP10vid_stream':
e:/programming/smpeg/video/parseblock.cpp:583: undefined reference to 
`IDCT_mmx(short*)'

They *are* getting assembled&linked- Why is this??
Here's the code for the mmxflags_asm.S, which should be enough for you 
folk to figure it out:
"
.text
     .align 2
.globl cpu_flags
     .def    cpu_flags;    .scl   2;      .type 32;    .endef
cpu_flags:
         pushfl
         popl %eax

         movl %eax,%edx

         xorl $0x040000,%eax
         pushl %eax

         popfl
         pushfl

         popl %eax
         xorl %ecx,%eax
         jz cpu_flags.L1   # Processor is 386

         pushl %ecx
         popfl

         movl %ecx,%eax
         xorl $0x200000,%eax

         pushl %eax
         popfl
         pushfl

         popl %eax
         xorl %ecx,%eax
         je cpu_flags.L1

         pushl %ebx

         movl $1,%eax
         cpuid
         movl %edx,%eax

         popl %ecx

cpu_flags.L1:
         ret

"

M@


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-23  1:53             ` Matt
@ 2006-08-23 17:33               ` Nick Clifton
  0 siblings, 0 replies; 17+ messages in thread
From: Nick Clifton @ 2006-08-23 17:33 UTC (permalink / raw)
  To: Matt; +Cc: binutils, drow

Hi Matt,

> Alright, I've managed to get both .S files to compile- however when I 
> try to link them with a program using:
> extern "C" {
> extern unsigned int cpu_flags(void);
> extern void IDCT_mmx(DCTBLOCK data);
> }
> 
> The linker tool comes up with
> ./.libs/libsmpeg.a(parseblock.o): In function `Z8InitIDCTv':
> e:/programming/smpeg/video/parseblock.cpp:117: undefined reference to 
> `cpu_flags()'

Probably because the compiler is adding a prefix of "_" to the 
"cpu_flags" and "IDCT_mmx" symbols.  Check the assembler output of the 
compiler to be sure.

If this is the problem then there are two ways around it:

   1.  Add the "_" prefix to the symbols in the assembler source.  eg:

         .globl _cpu_flags
         .def    _cpu_flags;    .scl   2;      .type 32;    .endef
       _cpu_flags:

   2.  Use the "Asm Labels" feature of gcc to force the correct name to 
be used.  (See the gcc documentation for more details).  eg:

       extern unsigned int cpu_flags (void) asm ("cpu_flags");

Cheers
   Nick

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-23  2:45             ` Matt
@ 2006-08-23 17:49               ` Pedro Alves
  0 siblings, 0 replies; 17+ messages in thread
From: Pedro Alves @ 2006-08-23 17:49 UTC (permalink / raw)
  To: Matt; +Cc: binutils

Matt wrote:
> Alright, I've managed to get both .S files to compile- however when I 
> try to link them with a program using:
> extern "C" {
> extern unsigned int cpu_flags(void);
> extern void IDCT_mmx(DCTBLOCK data);
> }
> 
> The linker tool comes up with
> ./.libs/libsmpeg.a(parseblock.o): In function `Z8InitIDCTv':
> e:/programming/smpeg/video/parseblock.cpp:117: undefined reference to 
> `cpu_flags()'
> ./.libs/libsmpeg.a(parseblock.o): In function 
> `Z15ParseReconBlockiP10vid_stream':
> e:/programming/smpeg/video/parseblock.cpp:583: undefined reference to 
> `IDCT_mmx(short*)'
> 
> They *are* getting assembled&linked- Why is this??
> Here's the code for the mmxflags_asm.S, which should be enough for you 
> folk to figure it out:
> "
> .text
>     .align 2
> .globl cpu_flags
>     .def    cpu_flags;    .scl   2;      .type 32;    .endef
> cpu_flags:
> 
> cpu_flags.L1:
>         ret
> 
> "
> 
> M@
> 

http://www.google.com/search?&q=mixing+assembly+and+c
    8.2.2 Using C Functions in Assembly Procedures
       should give you a hint...

Cheers,
Pedro Alves

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Smpeg MMX asm compilation (problem)
  2006-08-22  5:47           ` Pedro Alves
                               ` (2 preceding siblings ...)
  2006-08-23  2:45             ` Matt
@ 2006-08-24  8:33             ` Matt
  3 siblings, 0 replies; 17+ messages in thread
From: Matt @ 2006-08-24  8:33 UTC (permalink / raw)
  To: Pedro Alves, binutils

I'm not sure if that's relevant - I'm not calling the C functions from 
assembler, and the files are actually designed to be linked together by 
default in the original SMPEG installation - the only difference, in 
this case, is COFF- as opposed to ELF- if there's something wrong you 
can see, do point it out to me-
Cheers-
M@t

Pedro Alves wrote:
 >http://www.google.com/search?&q=mixing+assembly+and+c
 >   8.2.2 Using C Functions in Assembly Procedures
 >      should give you a hint...
 >
 >
 >Cheers,


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2006-08-24  3:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-20 19:59 Smpeg MMX asm compilation (problem) Matthew Bentley
2006-08-21  1:38 ` Daniel Jacobowitz
2006-08-21  1:54   ` Matthew Bentley
2006-08-21 15:25     ` Daniel Jacobowitz
2006-08-21 22:52     ` Pedro Alves
2006-08-22  1:10       ` Soul Studios
2006-08-22  3:05         ` Pedro Alves
2006-08-22  3:42         ` Brian Dessent
2006-08-22  5:47           ` Pedro Alves
2006-08-22 12:11             ` Nick Clifton
2006-08-22 17:22               ` Soul Studios
2006-08-23  1:53             ` Matt
2006-08-23 17:33               ` Nick Clifton
2006-08-23  2:45             ` Matt
2006-08-23 17:49               ` Pedro Alves
2006-08-24  8:33             ` Matt
2006-08-22  6:44           ` Matt Bentley

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).