-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create elf file directly on ARM? #65
Comments
AMaCC can generate ELF files on the ARMv7-A devices, and @splasky did verify the functionality. Can you simplify the steps to reproduce? |
gcc amacc.c -ldl None of the objdump or nm options seem to work on foo.o . I have even tried the Big Endian and Little Endian options. The object code generated is clearly ok though, because the Jit compile executes properly, as shown in my first post. Thanks. |
The elf generated by Amacc hasn't supported objdump yet. |
Let's close this issue and concentrate on further tooling ones. |
For anyone who wants to disassemble the ELF executable file that amacc produces, this hack works for everything but relocatable addresses: #!/bin/bash |
@HPCguy, I failed to utilize the above script to disassemble the ELF file generated by AMaCC. Only the following message:
|
Hi, The Issues editor won't allow me to paste the bash script as needed, although when I cut and paste out of the issue window into a script, it is working for me. I can create a pull request containing just the script, if you need it. Here is what I get for that disasm script: fact.c: int main(int argc, char *argv[]) % ./amacc -o foo fact.c 00000000 <.data>: Seeing the code allowed me to start adding optimizations to the backend, so the disasm functionality would likely be generally useful for others. |
PS Here is the optimized code, although I had to add a peephole optimizer to the backend assembly, even after the register assignment changes in codegen(). I haven't wrapped my head around the code enough to make it cleaner. There is obviously even more room for peephole optimizations looking at the code below. I left the old addresses on so you can do an sdiff. 0: e3a0b000 mov fp, #0 |
@HPCguy, Great work! Please send pull request(s). You can create a new directory |
pi@anchor:~/Languages/amacc $ uname -a
Linux anchor 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux
pi@anchor:~/Languages/amacc $ gcc amacc.c -ldl
pi@anchor:~/Languages/amacc $ cat count.c
int main()
{
int i;
for (i=0; i<10; ++i)
printf("%d\n", i) ;
return i;
}
pi@anchor:~/Languages/amacc $ ./a.out -o foo.o count.c
pi@anchor:~/Languages/amacc $ file foo.o
foo.o: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, stripped
pi@anchor:~/Languages/amacc $ objdump -d foo.o
objdump: foo.o: file format not recognized
??? --- Why doesn't this work?
pi@anchor:~/Languages/amacc $ ./a.out count.c
0
1
2
3
4
5
6
7
8
9
pi@anchor:~/Languages/amacc $
The text was updated successfully, but these errors were encountered: