Eclipse cross compiling in Ubuntu 16.04 - linux

My end goal is to write a C based application to run on a 32-bit linux ARM board as an embedded system. I am running a virtual 64-bit Ubuntu OS with Eclipse Neon and I am struggling with getting a useable executable file.
I have setup the cross compiler and I have made sure to build in 32-bit.
To check the file type and get more information on it I have used the command
> file hello.elf
I got sample hello world executable that does work and the output of the file command is
hello.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armf.so.3, for GNU/LINUX 2.6.32, BuildID
This program runs just fine, the output of the file command for my program (be-brave) is as follows, side note it's a simple hello world, I called it be-brave for motivation
be-brave.elf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/LINUX 3.2.0, BuildID
My guess is that the issue is the GNU/LINUX differemce meaning my cross compiler is not set right but I don't know for sure and even if that is the case I don't know how to fix it.
Any and all pointers/suggestions are greatly appreciated

I was able to find a workaround using the command line following this tutorial
Installing ARM cross compiler
I would still like to be able to use Eclipse so I will leave this question open in case anyone can help with that. I have a new issue, I am going to edit the original question to ask that

Related

why i can not run program on my linux(qemu simulate arm32,and start a linux os)

【1】, I have a linux os environment, which is based on arm32(qemu similute).
【2】, There are two file in / directory. One is "init", and one is "nesoft", but i can only run "init", and i can not run "nesoft" :
/ # ./init
This is initramfs - init !!!
/ # ./nesoft
-/bin/sh: ./nesoft: not found
【3】, The two file have dirrerence below:
zhang#zhang-Virtual-Machine:~/src/qemu/third_patry/rootfs/busybox/rootfs$ file init
init: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=08c7f187d91207660caa2db0101980a1f4b12716, notd
zhang#zhang-Virtual-Machine:~/src/qemu/third_patry/rootfs/busybox/rootfs$ file nesoft
nesoft: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 4.4.0, stripped
【4】, I have search ,so i think "LSB shared object" should run as executable file (I learn form https://unix.stackexchange.com/questions/472449/what-is-the-difference-between-lsb-executable-et-exec-and-lsb-shared-object )
BUT, why it still does not run ?
【END】
Has anyone meet this before, and know why ?
The main difference I see that second file is dynamically linked which means it requires library .so files to execute. I suppose it just that can't load the dependency.
Try running ldd (or export LD_TRACE_LOADED_OBJECTS=1 before running your binary since ldd may not be on busybox) to see which library is missing.

"Cannot execute binary file: Exec format error" x84-64 bit program running on aarch64 processor Debian 10

Basically I'm trying to run eclipse's 64bit linux installer on a 64 bit linux machine, but it's giving me an exec format error. All other solutions I've seen say it's usually an error with it not being the right processor speed.
My question is twofold. 1) What is going on here? 2) How do I properly download and install Eclipse?
I'm running linux through chromebook
Here is the output of a few command line statements
uname#loc:~/Desktop/eclipse-installer$ ./eclipse-inst
-bash: ./eclipse-inst: cannot execute binary file: Exec format error
uname#loc:~/Desktop/eclipse-installer$ file eclipse-inst
eclipse-inst: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b621fbc20e80d7ac375ece11a5775fc6686b71c7, with debug_info, not stripped
uname#loc:~/Desktop/eclipse-installer$ uname -m
aarch64
To answer your first question I think this could help:
You are trying to execute a program designed to run on a "x86_64" based processor using a processor designed based on "aarch64" architecture. These are two distinct architectures although they both may be using 64-bits for addressing and so forth, but it's not the matter of the bits. They are two completely different CPU designs.
For your second question I can not help because I don't use Eclipse.

Yocto - can not execute debug package

I was trying to install debug package of an application built by Yocto.
Aftre installation, the executables are found on .debug directory.
However, when I try to execute those I get the below error
-sh: /etc/.debug/app: cannot execute binary file: Exec format error
file command displays :
file /etc/.debug/app
/etc/.debug/app: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter *empty*, for GNU/Linux 2.6.32, BuildID[sha1]=1dfc051dc47683e0715b842998daadd4d12c541e, not stripped
arch command output is armv7l.
The app seems to be working fine [ the one with no debugg information].
And the file command on application is
file /etc/app
/etc/app: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=1dfc051dc47683e0715b842998daadd4d12c541e, stripped
What I want is to execute the application which is compiled using debug symbols, so that when the application crashes it gives coredump.
Is there a way to fix this or is there any other better method to run program using debug information [using Yocto framework ] ?
Debug packages contain just the debug symbols, you don't run them directly. Run the standard executables, and gdb will read the symbols that the debug package installed.

Cannot execute binary file error when running bibtex2html

I'm working on a project for a friend on a machine I'm not familiar with and I've run into some errors.
I'm running a program called bibtex2html, which is used to generate an HTML reference page. When I run the program, it gives me a "Cannot execute binary file" error.
From my preliminary research, it seems there are a number of causes to this problem, and I'm not really sure to begin.
What I've done so far:
uname -a ->
Linux baseline 2.6.38-15-generic-pae #60-Ubuntu SMP Tue May 22 11:48:17 UTC 2012 i686 i686 i386 GNU/Linux
file ~/bibtex2html/bibtex2html -> ~/bibtex2html/bibtex2html: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
You did all the research correctly, now you just need to interpret it. It's a 64-bit executable (x86-64), and you're on a 32-bit kernel (i686). You'll need to find or compile a 32-bit version of bibtex2html.

ELFsh Inject Compiled C code into an existing binary

I have hit a problem working with the ELFsh library, specifically when attempting to use the example in the testsuite which demonstrates injecting compiled C code into an existing binary.
What I've done so far is:
Checkout ELFsh from SVN (svn checkout http://svn.eresi-project.org/svn/trunk/ eresi)
./env.sh, ./configure --enable-32-64 --enable-m64, make, sudo make install. Also tried sudo make install64. After installing dependencies, the library built and installed fine.
eresi/testsuite/elf/etrel_inject/etrel_original contains the test I am interested in running. In there, I made a small change to the Makefile, which I believe has a small bug which is that -m32 is not explicitly specified in the all32 target which causes the result of all32 and all64 to be the same if compiled on a 64-bit system. Next:
I ran make (builds everything okay)
Now, my understanding of what is supposed to happen is that there is a target host.c which is compiled to hijackme32 and hijackme64. These are 32 and 64 bit binaries to which rel.32.o and rel.64.o are injected to respectively.
This injection can be performed in two ways in the test - through the ELFsh script (relinject32.esh and relinject64.sh) and through the C API (relinject32 and relinject64).
Running relinject32 results in:
[E] Unable to load object
Running relinject64 results in:
[E] Unable to copy PLT
To get finer grained information about where the problem lies, I loaded up ELFsh interactively and went through the steps of relinject32/64.esh one by one. Both scripts fail on loading of the target:
(elfsh-0.82-b2-dev#local) load hijackme32
[E] Cannot load object
(elfsh-0.82-b2-dev#local) load hijackme64
[*] Sun Mar 18 02:49:04 2012 - New object loaded : hijackme64
Architecture EM_X86_64 : AMDx86-64 architecture not supported. No flowjack available.
[E] Libmjollnir unsupported architecture
Oddly, attempting to load the 32-bit target with its full path results in a different error:
(elfsh-0.82-b2-dev#local) load /home/mike/Desktop/eresi/testsuite/elf/etrel_inject/etrel_original/hijackme32
Architecture EM_X86_64 : AMDx86-64 architecture not supported. No flowjack available.
[E] Cannot load object
This is surprising because the OS produces:
mike#mike-linux:file hijackme32
hijackme32: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
mike#mike-linux:file hijackme64
hijackme64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
The current system I am testing on is x86-64 Ubuntu.
My question is how do I get this test to run? Am I setting up the environment or building incorrectly?
I tried going on the IRC (preferred method of communication), but the project (and channel) seem pretty much dead now.

Resources