I am playing around with programming in assembly and I have run in to a couple of issues. I hope that someone can help me figure out what I am missing.
I created an empty project for the XC-1A. I added a main.s file with a .globl main label in a .text section that does nothing. When I try to compile it I get "ERROR: Unable to open output file '../.build_Debug/src/main.s.o' for writing elf".
When I add a blank .c file everything compiles and links successfully.
If, at this point, I make the main label local (remove .globl) then I get "crt1.S: Error: Undefined reference to 'main'". I imagine that this is the C runtime failing to link due to a missing symbol.
So, my two questions. 1. How do I get a project to compile with just .s files? 2. How do I get the project to not use the C runtime?
Assembly project without C
-
- Member++
- Posts: 21
- Joined: Sun Mar 03, 2013 11:26 pm
-
- Respected Member
- Posts: 318
- Joined: Tue Dec 15, 2009 12:46 am
This appears to be a bug with the makefiles, I've filed a bug here:diltsman wrote:I am playing around with programming in assembly and I have run in to a couple of issues. I hope that someone can help me figure out what I am missing.
I created an empty project for the XC-1A. I added a main.s file with a .globl main label in a .text section that does nothing. When I try to compile it I get "ERROR: Unable to open output file '../.build_Debug/src/main.s.o' for writing elf".
https://github.com/xcore/xcommon/issues/15
This bug only affects lowercase .s files, not uppercase .S files. For now I suggest you rename you assembly files to use the .S extension. This also lets you use the C preprocessor (#includes, macros, C style comments).
This is correct. The following options can be used to control what you link against:diltsman wrote:If, at this point, I make the main label local (remove .globl) then I get "crt1.S: Error: Undefined reference to 'main'". I imagine that this is the C runtime failing to link due to a missing symbol.
Code: Select all
-nodefaultlibs Compile without system libraries
-nostartfiles Compile without system startup files
-nostdlib Compile without system libraries and startup files
One issue you might run into is that the order in which the object files are linked is unspecified, so if you have multiple input files the you won't know which code gets executed first. If you are calling xcc directly you can solve this by compiling this startup code into an object file and using:
Code: Select all
xcc -nostartfiles -Xmapper --first -Xmapper startup.o <other input files here>
-
- Member++
- Posts: 21
- Joined: Sun Mar 03, 2013 11:26 pm
When I added the flags to XCC_MAP_FLAGS it didn't work. When I added them to XCC_MAP_FLAGS_Release and XCC_MAP_FLAGS_Debug it did. Is this expected behavior?richard wrote:To use these in the Makefile add these to the XCC_MAP_FLAGS variable.
-
- Experienced Member
- Posts: 104
- Joined: Fri Dec 11, 2009 8:29 pm
That is expected behaviour. If you have XCC_FLAGS_Release and XCC_FLAGS_Debug then this defines two build configurations and all other flags (XCC_MAP_FLAGS, XCC_ASM_FLAGS etc) need to be set with the prefix relevant to the build config.diltsman wrote:When I added the flags to XCC_MAP_FLAGS it didn't work. When I added them to XCC_MAP_FLAGS_Release and XCC_MAP_FLAGS_Debug it did. Is this expected behavior?richard wrote:To use these in the Makefile add these to the XCC_MAP_FLAGS variable.
If you only want one build configuration you can omit the suffices on all the settings.
Dave