> Do you have any advice to make the code work both under Apple and GNU gcc?
The leading underscore for external symbols is standard, if that's what you're referring to. http://en.m.wikipedia.org/wiki/Underscore#Origins_in_identifiers
So it turns out that I was wrong. It, in fact, is not standard. But regardless, you can use asm to specify the exact name. Eg.
extern int func() asm("func");
You can read more here: http://stackoverflow.com/questions/1034852/adding-leading-underscores-to-assembly-symbols-with-gcc-on-win32
Despite the title of the thread, the solution is compiler and system independent.
_______________________________________________
Hi Ashi,
Your first LDR is a pseudoinstruction that is supported by some tools (gas and armasm, at least), but not by LLVM. Roughly speaking, it turns into a PC-relative load from a literal pool.
To do what you're trying to achieve you can write your own literal pool in your assembly. You can see some examples of this sort of thing at https://github.com/tianocore/edk2/blob/master/ArmPkg/Include/AsmMacroIoLib.h.
Regards,
Bernie
Not sure, but I would try:
1. Are the objects being linked in the right order?
2. Is the symbol name _data_table correct?
3. You may need to explicitly tell your use_table.s file about the existence of data_table. In armasm I would have an 'import' statement to achieve this, not sure about clang/gas.
You also need to return from foo _before_ you execute '.long _data_table'. And be warned that the PC doesn't point at the next instruction when you use it like this - I believe you don't need to modify it at all if you swap the pop and the .long.
IIRC, reads of the PC must behave as they did when ARM processors had three-stage pipelines, regardless of the length of the actual pipeline. The consequence is that, when using PC in this way, it's value will be 2 instructions ahead of the address of the current instruction. This is so that software remains portable across cores.
From: Ashi [mailto:ashi...@gmail.com]
Sent: 08 March 2013 04:44
To: Tim Northover
Cc: Bernard Ogden; LLVM List
Subject: Re: [LLVMdev] ARM assembler's syntax in clang
> And be warned that the PC doesn't point at the next instruction when you use it like this - I believe you don't need to modify it at all if you swap the pop and the .long.