graphitemaster / incbin

Include binary files in C/C++
The Unlicense
941 stars 90 forks source link

Sadly does not work on ARM/Raspberry #12

Closed ahupowerdns closed 8 years ago

ahupowerdns commented 8 years ago

I love incbin, we use it in PowerDNS. Sadly, it does not work on ARM, specifically on our Raspberry PIs. And this is of course a very important target audience. Has anyone managed to find the #ifdefs to make it work?

It spews out:

/tmp/ccHhbOO1.s: Assembler messages:
...
/tmp/ccaQN9ku.s:140: Error: unrecognized symbol type ""
/tmp/ccaQN9ku.s:145: Error: unrecognized symbol type ""
/tmp/ccaQN9ku.s:150: Error: unrecognized symbol type ""
/tmp/ccaQN9ku.s:157: Error: unrecognized symbol type ""

This is line 140:

.type gjs_rickshaw_min_jsData, @object

145:

.type gjs_rickshaw_min_jsEnd, @object

With some context:

 .section .rodata
.global gjs_rickshaw_min_jsData
.type gjs_rickshaw_min_jsData, @object
.align 4
gjs_rickshaw_min_jsData:
.incbin "./dnsdistdist/html/js/rickshaw.min.js"
.global gjs_rickshaw_min_jsEnd
.type gjs_rickshaw_min_jsEnd, @object
.align 1
gjs_rickshaw_min_jsEnd:
.int 1
.global gjs_rickshaw_min_jsSize
.type gjs_rickshaw_min_jsSize, @object
.align 4
gjs_rickshaw_min_jsSize:
.int gjs_rickshaw_min_jsEnd - gjs_rickshaw_min_jsData

This looks exactly like what gets emitted on x86-64, except for the .aligns etc. Perhaps on ARM the '@object' syntax does not work?

Help!

IngwiePhoenix commented 8 years ago

This could be an issue with the assembler itself. Try using a different compiler. It seems that you use GCC at the moment; please try to test this with Clang as well just to confirm.

ahupowerdns commented 8 years ago

Interesting, this generated different but more verbose errors:

<inline asm>:3:24: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gindex_htmlData, @object
                       ^
<inline asm>:8:23: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gindex_htmlEnd, @object
                      ^
<inline asm>:13:24: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gindex_htmlSize, @object
                       ^
<inline asm>:19:23: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type glines_cssData, @object
                      ^
<inline asm>:24:22: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type glines_cssEnd, @object
                     ^
<inline asm>:29:23: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type glines_cssSize, @object
                      ^
<inline asm>:35:23: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type ggraph_cssData, @object
                      ^
<inline asm>:40:22: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type ggraph_cssEnd, @object
                     ^
<inline asm>:45:23: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type ggraph_cssSize, @object
                      ^
<inline asm>:51:22: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type glocal_jsData, @object
                     ^
<inline asm>:56:21: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type glocal_jsEnd, @object
                    ^
<inline asm>:61:22: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type glocal_jsSize, @object
                     ^
<inline asm>:67:24: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_purl_jsData, @object
                       ^
<inline asm>:72:23: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_purl_jsEnd, @object
                      ^
<inline asm>:77:24: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_purl_jsSize, @object
                       ^
<inline asm>:83:25: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_d3_v3_jsData, @object
                        ^
<inline asm>:88:24: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_d3_v3_jsEnd, @object
                       ^
<inline asm>:93:25: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_d3_v3_jsSize, @object
                        ^
<inline asm>:99:30: error: expected STT_<TYPE_IN_UPPER_CASE>, '#<type>', '@<type>', '%<type>' or "<type>"
.type gjs_moment_min_jsData, @object
IngwiePhoenix commented 8 years ago

This certainly is interesting…

If you have experience with ASM, maybe you could poke around inside incbin.h ? It looks like that the instructions read by the assembler don’t match an ARM assembler’s expectations.

I am not an assembler dude myself, i just use incbin on your daily OS X and windows systems (:

graphitemaster commented 8 years ago

This is actually pretty funny. The assembler interprets @ as a line comment. This is easy to fix. Already pushed one./