views:

162

answers:

1

Hello everyone. While trying to compile my project, that uses some third party headers, with mingw 4.4, I encountered the following error:

Assembler messages:
Error: junk at end of line, first unrecognized character is '"'
Error: unknown pseudo-op: '.previous'

I found this code at the end of one of the included headers:

__asm__(".section \".plc\"");
__asm__(".previous");

Since I do not have any experience at all with in-line assembler instructions, I googled for an explanation to it, but couldn't find the answer to my two basic questions. What does __asm__(".previous"); acctually do and why would anyone put this at the end of a header file.

These are the only __asm__ instructions in the whole project. Can I safely delete them? Or is there a way to define .previous in order to make it a known pseudo-op?

Enlighten me, please!

+2  A: 

.previous is a directive that lets you swap back and forth between two elf sections. It is a shortcut that allows denser assembly files and lets you for example declare initialized data within a stream of code or vice versa.

For example say you have an assembler file with a data and a code section.

If you want - in the middle of a function - declare a constant in the data segment you can use the .previous statement like this:

  nop            // some code

.previous        // swaps current section (code) with previous section (data)

MyConstant:
  .word 0x0001   // some data

.previous        // swaps curent section (data) with previous section (code)

  nop            // more code

More information can be found in the reference manual:

http://sourceware.org/binutils/docs-2.19/as/Previous.html#Previous

Nils Pipenbrinck
Since there aren't any instructions after "__asm__(".previous");"in my code sample, it simply declares a new section ".plc" and swaps some empty code into it. Is this correct? So deleting it would not have any impact on the compiled application.
NullAndVoid