使用Oracle VirtualBox在Eclipse CDT中的组装中的“ Hello World”:构建失败

问题描述

我正在尝试使用打印Hello World的AT&T语法在GNU汇编器中编写64位汇编语言程序。我正在与GCC关联。

在Oracle VirtualBox上使用Debian 10,x86_64体系结构,Eclipse CDT 2020-09

注意:使用命令行在NASM中构建成功

也张贴在CDT下的elclipse.org/Forums上。但是没有解决办法

已执行的步骤:

文件>新建>项目> C项目>空项目,Linux GCC

项目名称:HelloASM>下一步>调试,发布>完成

文件>新建>源文件>源文件:hello.S>完成

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

项目>构建项目

错误

09:46:57 **** Build of configuration Debug for project HelloASM ****
make all 
Building file: ../hello.S
Invoking: GCC Assembler
as  -o "hello.o" "../hello.S"
Finished building: ../hello.S
 
Building target: HelloASM
Invoking: GCC C Linker
gcc  -o "HelloASM"  ./hello.o   
/usr/bin/ld: ./hello.o: relocation R_X86_64_32 against `.data' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link Failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [makefile:31: HelloASM] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

09:46:58 Build Failed. 3 errors,0 warnings. (took 666ms)

为什么会出现此链接错误,该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)