flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > CMake ARM errors: unrecognized opcode: func_export ...?

Author
Thread Post new topic Reply to topic
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 13:57
(1) I’m getting CMake assembler errors such as:

testing.s:137: Error: unrecognized opcode: ‘func_export(testing)’
testing.s:146: Error: unrecognized opcode: ‘func_begin(testing)’
testing.s:217: Error: unrecognized opcode: ‘func_end(testing)’
testing.s:149: Error: unsupported relocation against r3
testing.s:162: Error: unsupported relocation against r4
testing.s:187: Error: unsupported relocation against r5

(2) Question: What can I do about these errors?

My assembly code (in file testing.s) looks something like the following code. I’ve removed a lot of it and am trying to be concise.
Code:
    #define _ASMLANGUAGE
    #include “vxWorks.h”
    #include <asm.h>

    FUNC_EXPORT(testing)
    .text
    .align 2
    .long 0
    .long 1
    .globl testing
    FUNC_BEGIN(testing)
    li r3, 1
    ori r4, r4, 0x6789
    srw r4, r4, r5
    FUNC_END(testing)
    

(3) My CMakeLists.txt looks something like:
Code:
    cmake_minimum_required (VERSION 2.6)
    project(testing LANGUAGES CXX ASM)
    set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -Wall -g -std=c++0x -Wextra -Wpedantic”)
    set(dir3 …///util/dir3)
    add_executable(testing
    ${dir3}/one.cpp
    ${dir3}/testing.s
    )
    

(4) File one.cpp looks something such as:
Code:
    extern “C” int testing(void);
    //…
    testing();
    //

Thank you,
Post 02 Mar 2020, 13:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 02 Mar 2020, 14:50
I don't know anything about your CMake, but something that stands out from your error report is that "func_export" != "FUNC_EXPORT". Perhaps you need to match the lower/upper case.

Also, your sample code doesn't have enough lines (only 15 lines) because your error report shows line numbers greater than that.
Post 02 Mar 2020, 14:50
View user's profile Send private message Visit poster's website Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 15:03
revolution wrote:
I don't know anything about your CMake, but something that stands out from your error report is that "func_export" != "FUNC_EXPORT". Perhaps you need to match the lower/upper case.

Also, your sample code doesn't have enough lines (only 15 lines) because your error report shows line numbers greater than that.

In the assembly code, I changed the case of FUNC_EXPORT to lower case, but I got the same assembler error: Error: unrecognized opcode: 'func_export(testing)'.

Yes, my sample program has 15 lines and the real program has many more lines to it. I did this to indicate that what I posted to the group was indeed a summary of the real program. So, what was posted was never assembled. I simply tried to summarize the real program as best I could. Anyway, the owner of the real program won't let me post it. It's a trivial program, but he said "nope."

The posted program uses assembly instructions that were grabbed from different parts of the real program. I just wanted to show the use of the registers. So, there is no real logic in the posted program. It's not meant to do anything of substance.
Post 02 Mar 2020, 15:03
View user's profile Send private message Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 15:10
When I searched the Internet to see what other people had done, I found only this. It didn't help me.

Subject: “Error: unsupported relocation against <register>” error with inline PPC assembly code in .c file

https://stackoverflow.com/questions/30253742/error-unsupported-relocation-against-register-error-with-inline-ppc-assembl
Post 02 Mar 2020, 15:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 02 Mar 2020, 15:14
We don't know how you have defined your stuff. Perhaps your includes have done something weird.

Please make some minimal sample that you run through CMake and then show the errors for that file. Try not to use #include unless you can also post the included file.
Post 02 Mar 2020, 15:14
View user's profile Send private message Visit poster's website Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 15:33
As you requested, the error messages followed by the ARM assembly program without the includes is.

Code:
testing.s: Assembler messages:
testing.s:3: Error: unrecognized opcode: `func_export(testing)'
testing.s:9: Error: unrecognized opcode: `func_begin(testing)'
testing.s:13: Error: unrecognized opcode: `func_end(testing)'
testing.s:10: Error: unsupported relocation against r3
testing.s:11: Error: unsupported relocation against r4
testing.s:11: Error: unsupported relocation against r4
testing.s:12: Error: unsupported relocation against r4
testing.s:12: Error: unsupported relocation against r4
testing.s:12: Error: unsupported relocation against r5
    

Code:
    #define _ASMLANGUAGE

    func_export(testing)
    .text
    .align 2
    .long 0
    .long 1
    .globl testing
    func_begin(testing)
    li r3, 1
    ori r4, r4, 0x1000
    srw r4, r4, r5
    func_end(testing)
    
    
Post 02 Mar 2020, 15:33
View user's profile Send private message Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 15:45
The case of the registers doesn't remove the error. For example, if I change "r3" to "R3" throughout the assembly code I get the assembler error message:

Code:
Error: unsupported relocation against R3.
    
Post 02 Mar 2020, 15:45
View user's profile Send private message Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 16:17
What would the inline assembly look like for this program in c++?
Post 02 Mar 2020, 16:17
View user's profile Send private message Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 16:33
Mike090 wrote:
What would the inline assembly look like for this program in c++?


When I put the following code in the C++ source code,

Code:
 
         __asm__ ( "movl $10, %eax;"
                   "movl $20, %ebx;"
                   "addl %ebx, %eax;"
                   "li   r3, 1"
         );
    

I get the following:

Assembler messages:
Error: unrecognized opcode: `movl'
Error: unrecognized opcode: `movl'
Error: unrecognized opcode: `addl'
Error: unsupported relocation against r3


Last edited by Mike090 on 02 Mar 2020, 16:41; edited 1 time in total
Post 02 Mar 2020, 16:33
View user's profile Send private message Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 16:37
This program is being run on Linux.
Post 02 Mar 2020, 16:37
View user's profile Send private message Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 02 Mar 2020, 17:06
When I compile using the "-v" option, I see that the compiler is GNU C++11 (version 8.2.0) and GNU assembler version 2.31.1 is the assembler. I obtained this information using the "-v" compiler option.
Post 02 Mar 2020, 17:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 02 Mar 2020, 21:13
I can only offer generic advice because I have no idea what your CMake is.

'func_export' isn't an instruction. So I think the error message is accurate there. Is it a macro defined somewhere else?

ARM doesn't have instructions movl or addl. So the error message is telling you that.

The registers might be needed to be supplied as numbers, as is indicated by the SO page you linked above.

Try starting with just a single instruction that has no parameters to make sure you can compile things. Then move up to gradually adding more things. Is there some example code in the docs?
Post 02 Mar 2020, 21:13
View user's profile Send private message Visit poster's website Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 03 Mar 2020, 13:31
Thank you for the information, someone else gave me additional useful information.

I was given the following two links:

gcc.gnu.org/onlinedocs/gcc/Extended-Asm.htm

stackoverflow.com/questions/199966/how-do-you-use-gcc-to-generate-assembly-code-in-intel-syntax

So, I have to convert nonsense code similar to the following code from the "intel" dialect to the "att" dialect.

Code:
#define _ASMLANGUAGE
#include “vxWorks.h”
#include <ash.h>

FUNC_EXPORT(testing)
 .text
 .align 2
 .long 0
 .long 1
 .globl testing

FUNC_BEGIN(testing)
   li r3, 1
   ori r4, r4, 0x6789
   srw r4, r4, r5
   add    r4, r4, r3
   subi   r3, r3, 2
   cmplw r4, r5
   bne GOIT
   FUNC_END(testing)

GOIT:
    


Question: Do you see any problems in converting these instructions to the "att" dialect?
Post 03 Mar 2020, 13:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 04 Mar 2020, 16:36
I'm not aware of any AT&T syntax defined for ARM code.

AFAIK there is only the ARM syntax. AT&T and Intel have never had any say about the ARM instructions.
Post 04 Mar 2020, 16:36
View user's profile Send private message Visit poster's website Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 04 Mar 2020, 18:44
I just put a percent sign in front of every register and it assembled without any errors.
Post 04 Mar 2020, 18:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 05 Mar 2020, 06:32
Mike090 wrote:
I just put a percent sign in front of every register and it assembled without any errors.
Glad you got it working.

But how did that fix the "Error: unrecognized opcode: ‘func_export(testing)’"?
Post 05 Mar 2020, 06:32
View user's profile Send private message Visit poster's website Reply with quote
Mike090



Joined: 02 Mar 2020
Posts: 12
Location: Missouri, United States
Mike090 05 Mar 2020, 12:36
That was completely deleted.
Post 05 Mar 2020, 12:36
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.