In Eclipse CDT, I created an Assembly Project and Source File:
File > New > Project > C Project
Empty Project, Cross GCC
Project Name: HelloAsm
Next>
Debug and Release > Finish
Project > Properties > C/C++ Build > Settings
GCC Assembler>
Command: as
Commandline Patterns:
${COMMAND} ${FLAGS} -g --gstabs ${OUTPUT_FLAG} ${OUTPUT_PREFIX}
${OUTPUT} ${INPUTS}
Apply and Close
File > New > Source File
Source Folder: HelloAsm
Source File: hello.S
Finish
hello.S:
.section .data
message: .string "Hello World!\n"
.section .text
# this directive allows the linker to see the "main" label
# which is our entry point
.globl main
# this directive allows the eclipse gdb to see a function called "main"
.func main
main:
mov $4, %eax
mov $1, %ebx
mov $message, %ecx
mov $14, %edx
int $0x80
mov $0, %eax
Project > Build Project
Error..
Console:
"make all" terminated with exit code 2. Build might be incomplete.
09:41:31 Build Failed. 3 errors, 0 warnings. (took 504ms)
Problems:
./hello.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIC FirstAsm C/C++ Problem
final link failed: nonrepresentable section on output FirstAsm C/C++ Problem
make: *** [makefile:31: FirstAsm] Error 1 FirstAsm C/C++ Problem
Any help?