Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 无法运行使用gcc生成的可执行文件_Linux_Gcc_Toolchain_Crouton Os - Fatal编程技术网

Linux 无法运行使用gcc生成的可执行文件

Linux 无法运行使用gcc生成的可执行文件,linux,gcc,toolchain,crouton-os,Linux,Gcc,Toolchain,Crouton Os,我已经建立了一个新的环境——它是一个Chromebook(基于Asus flip C100P-ARM)中包含Ubuntu 14.04(trusty)的chroot。我已经安装了gcc和g++。我创建了一个简单的“hello,world”程序(test.c),并通过以下方式进行编译: gcc -o t.exe test.c 当我运行./t1.exe时,我得到以下信息: bash: ./t.exe: Permission denied 请注意,我是以root用户身份执行的,./t.exe上的权

我已经建立了一个新的环境——它是一个Chromebook(基于Asus flip C100P-ARM)中包含Ubuntu 14.04(trusty)的chroot。我已经安装了gcc和g++。我创建了一个简单的“hello,world”程序(test.c),并通过以下方式进行编译:

 gcc -o t.exe test.c
当我运行./t1.exe时,我得到以下信息:

bash: ./t.exe: Permission denied
请注意,我是以root用户身份执行的,./t.exe上的权限设置为全开(chmod 777,通过ls-l验证)

所以我试着确定出了什么问题-以下是我试过的:

%文件。/t.exe

./t.exe: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=82a6c6227e0f7171a68c71a74c6e6396e37e6675, not stripped
%ldd./t.exe

not a dynamic executable
%readelf-d./t.exe |需要grep

0x00000001 (NEEDED)                     Shared library: [libc.so.6]
%dpkg-l libc6

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libc6:armhf    2.19-0ubuntu armhf        Embedded GNU C Library: Shared li
%cat/etc/ld.so.conf.d/*

# Multiarch support
/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabihf/mesa-egl
/usr/lib/arm-linux-gnueabihf/mesa
/usr/lib/arm-linux-gnueabihf/libfakeroot
# libc default configuration
/usr/local/lib
%ls-l libc.so.6

lrwxrwxrwx 1 root root 14 Aug 12 19:37 libc.so.6 -> /lib/libc.so.6
%ls-l/usr/local/lib/libc.so.6

lrwxrwxrwx 1 root root 14 Aug 12 19:37 libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 18:21 /usr/local/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 19:37 /usr/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 34 Aug 12 18:11 /lib/libc.so.6 -> /lib/arm-linux-gnueabihf/libc.so.6
lrwxrwxrwx 1 root root 12 May 26 07:55 /lib/arm-linux-gnueabihf/libc.so.6 -> libc-2.19.so
%ls-l/usr/lib/libc.so.6

lrwxrwxrwx 1 root root 14 Aug 12 19:37 libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 18:21 /usr/local/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 19:37 /usr/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 34 Aug 12 18:11 /lib/libc.so.6 -> /lib/arm-linux-gnueabihf/libc.so.6
lrwxrwxrwx 1 root root 12 May 26 07:55 /lib/arm-linux-gnueabihf/libc.so.6 -> libc-2.19.so
%ls-l/lib/libc.so.6

lrwxrwxrwx 1 root root 14 Aug 12 19:37 libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 18:21 /usr/local/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 19:37 /usr/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 34 Aug 12 18:11 /lib/libc.so.6 -> /lib/arm-linux-gnueabihf/libc.so.6
lrwxrwxrwx 1 root root 12 May 26 07:55 /lib/arm-linux-gnueabihf/libc.so.6 -> libc-2.19.so
%ls-l/lib/armlinuxgnueabihf/libc.so.6

lrwxrwxrwx 1 root root 14 Aug 12 19:37 libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 18:21 /usr/local/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 14 Aug 12 19:37 /usr/lib/libc.so.6 -> /lib/libc.so.6
lrwxrwxrwx 1 root root 34 Aug 12 18:11 /lib/libc.so.6 -> /lib/arm-linux-gnueabihf/libc.so.6
lrwxrwxrwx 1 root root 12 May 26 07:55 /lib/arm-linux-gnueabihf/libc.so.6 -> libc-2.19.so
%ls-l/lib/armlinux-gnueabihf/libc-2.19.so

-rwxr-xr-x 1 root root 902876 May 26 07:56 /lib/arm-linux-gnueabihf/libc-2.19.so
/lib/arm-linux-gnueabihf/libc-2.19.so:     file format elf32-littlearm
%objdump-a/lib/armlinux gnueabihf/libc-2.19.so

-rwxr-xr-x 1 root root 902876 May 26 07:56 /lib/arm-linux-gnueabihf/libc-2.19.so
/lib/arm-linux-gnueabihf/libc-2.19.so:     file format elf32-littlearm
/lib/armlinux gnueabihf/libc-2.19.so

%objdump-a./t.exe

./t.exe:     file format elf32-littlearm
./t.exe

%联阿援助团

Linux localhost 3.14.0 #1 SMP PREEMPT Tue Aug 2 21:07:06 PDT 2016 armv7l armv7l armv7l GNU/Linux
我怀疑我有一个坏掉的工具链,但在这一点上我真的被难住了。

有人知道这里发生了什么或者如何找到问题吗?

所以我原来使用的是一个可移动SD卡上的目录,我也用那张卡来存放加密的chroot。(顺便说一句,不推荐-非常慢。)因此,ChromeOS和Ubuntu可以看到并访问该目录,而无需明确设置共享

在网上寻找答案时,我偶然发现了以下内容:。 事实证明,我的/etc/fstab文件实际上是空的——其中只包含“#未配置的基本系统fstab”

查看“mount”的输出,SD卡上的文件系统似乎是用“noexec”挂载的。我相信这就是我的问题的根源——我想我可以为这个文件系统添加一个带有“exec”标志的fstab条目,一切都应该正常

但是,进一步考虑一下,我决定不这样做——毕竟,我只需要加密文件系统中的项目(SD卡上的容器文件)就可以执行文件,而让SD卡文件系统上的文件直接执行可能会稍微不安全。因此,我决定简单地将用于开发工作的目录树更改为我的用户主目录下(它位于chroot中Ubuntu使用的加密文件系统中,显然位于容器文件的SD卡上,但不直接位于SD卡分区本身的文件系统中)。我放弃了对chroot和ChromeOS环境中文件的即时访问,但是,如果我将来真的需要,我可以设置一个共享—可能在单独的设备/分区(USB闪存驱动器)上


这对我的chromebook有效。我也有同样的问题。

我正在Chromebook上通过
crouton
运行Linux。我正在学习
go
编程语言,能够让
go
解释我的“Hello,World!”程序,但是当我让它编译代码时,我无法运行生成的二进制代码。我忘记了这个
noexec
问题。我所要做的就是用
exec
重新安装SD卡,权限就解决了

对我来说是:


sudo挂载-o重新挂载,exec/media/removable/SD\Card

哇,我把这个Q保存下来,以便查看令人惊讶的CMD列表。。。但是,请尝试
printf“#!/bin/bash\necho Hello Scripting!\n”>。/myTest.sh;chmod 755 myTest.sh/myTest.sh
。(我可能错过了一个
等,但希望你能理解)。如果此操作失败,则说明您的
/
dir或“上面”目录之一的权限有问题。请参阅以获取一些想法。祝你好运。你试过用类似于
-march=i686
的东西编译吗?看起来你的二进制文件是为Chromebook生成的,而不是为Ubuntu生成的(你可以尝试将可执行文件复制到Chromebook,它应该在那里运行,这证实了这一点)。@Mondkin-错误的架构。这是在手臂上。即使我为我的手臂指定了选项,我也不认为这会有什么不同。我不理解你的评论——“是为Chromebook而不是Ubuntu生成的”;我没有使用交叉工具集。我在Chromebook上运行crouton中的Ubuntu,我在运行Ubuntu的chroot中执行gcc。@Shedder-我承认,当我读到你的建议时,我做了一些鬼脸,因为我真的认为我已经证明这不是权限/隐私问题。不过,我还是试了一下(只是为了彻底了解一下)。。。瞧,我甚至不能执行那个简单的bash脚本!所以我在深入挖掘。非常感谢。进一步的研究表明,我实际上可以将生成的可执行文件mv到我的主目录中,并且从那里它可以很好地执行。因此,我最初构建可执行文件的位置(目录树中的某个地方的权限?)似乎有问题。但是因为可执行映像运行没有问题,所以我的工具链看起来很好——这似乎是一个环境问题。如果/当我找到根本原因时,我会再次更新,以防将来有人遇到这个问题并在搜索中找到它。