Home » Language IDEs » C / C++ IDE (CDT) » How to create a makefile in Assembly in Eclipse CDT, without C file?('makefile' in gas (.S file) in CDT, without using C (.c file))
How to create a makefile in Assembly in Eclipse CDT, without C file? [message #1834532] |
Wed, 11 November 2020 23:51 |
Tom KPB Messages: 18 Registered: November 2020 |
Junior Member |
|
|
Using Debian 10, x86-64 Architecture, and Eclipse CDT 2020-09.
Steps Followed:
(1) Create a Project
File > New > Project > C/C++ Project > C Project
Project name: HelloAsmMakefile
Project type: Makefile project > Empty Project, Linux GCC > Finish
(2) Create Source File
New > Source File Source File: hello.S
.text
.global main # must be declared for linker (ld)
.func main
main: # tells linker entry point
mov $len, %edx # message length
lea msg(%rip), %rsi # message to write (RIP relative addressing)
mov $1, %edi # file descriptor (stdout)
mov %edi, %eax # system call number (sys_write)
syscall
ret
.data
msg: .ascii "Hello, world!\n"
len = . - msg # length of the msg string
(3) Create a makefile
New > File > Filename: 'makefile' > Finish
Issue:
Most of the solutions are either using (1) C and AS files together, (2) 32-bit, (3) NASM, or (4) .asm file extension.
How do I create a makefile exclusively for gas (without C file), for CDT?
[Updated on: Wed, 11 November 2020 23:53] Report message to a moderator
|
|
|
Re: How to create a makefile in Assembly in Eclipse CDT, without C file? [message #1834536 is a reply to message #1834532] |
Thu, 12 November 2020 04:12 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
You clearly don't understand what Make does.
A makefile consists of rules.
Each rule has three parts:
- target
- prerequisite(s)
- recipe
The target and prerequisites are files.
If any of the prerequisites are newer than the target
then Make executes the recipe in a shell to create or update the target.
The rules are examined in topological order.
Meaning Make determines which should be examined first.
The target and prerequisites can be generic.
For .S files a generic rule to assemble one to create an object file might be:
%.o: ../%.S
@echo 'Building file: $<'
@echo 'Invoking: GCC Assembler'
as -g --gstabs -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
In fact, that's the one generated by Eclipse for the ASMHello test I did for your previous question(s).
%.o is the target (an object file with the same name as the source)
%.S the prerequisite for the .o file (the source)
the rest is the recipe.
Eclipse will generate one for each source file type in the project.
And only if it is a Managed Build project.
If you don't want Eclipse generating rules for .c or .cpp files,
then don't put them in your project.
The makefiles generated by Eclipse are quite rudimentary.
Make can be confusing but you really need to knuckle down and learn it.
Here is the Introduction to Makefiles in the GNU Make manual:
https://www.gnu.org/software/make/manual/html_node/Introduction.html
Here's the entire manual:
https://www.gnu.org/software/make/manual/html_node/index.html
All of this is off-topic for this forum which is to address issues with CDT.
The forum is not meant to provide introductions, detailed instructions or discussions on using any particular external tool.
If you are truly interested, I suggest reading the manual
and perhaps Googling gnu make tutorial
or how to use gnu make
[Updated on: Thu, 12 November 2020 04:45] Report message to a moderator
|
|
| | | |
Re: How to create a makefile in Assembly in Eclipse CDT, without C file? [message #1835082 is a reply to message #1834532] |
Tue, 24 November 2020 13:05 |
Tauno Voipio Messages: 742 Registered: August 2014 |
Senior Member |
|
|
luna grover wrote on Tue, 24 November 2020 03:21Most of the solutions are either using (1) C and AS files together, (2) 32-bit, (3) NASM, or (4) .asm file extension.
If you respond to my solutions:
(1) There is no C with embedded assembly,
(2) The solutions are for both 32 bit and 64 bit systems,
(3) There is no NASM, but GNU as instead,
(4) There is no .asm extension, but .S and .s
--
Tauno Voipio
|
|
| |
Goto Forum:
Current Time: Wed Oct 09 04:21:57 GMT 2024
Powered by FUDForum. Page generated in 0.04531 seconds
|