Closed kempniu closed 8 years ago
Have you tested this? Because I don't see how it could work as INCBIN_PREFIX
won't be evaluated before concatenation.
For INCBIN_GLOBAL()
and INCBIN_TYPE()
, you could do something like:
# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
...
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n"
...
#define INCBIN(NAME, FILENAME) \
__asm__(INCBIN_SECTION \
INCBIN_GLOBAL(NAME ## Data) \
INCBIN_TYPE(NAME ## End) \
...
For INCBIN_EXTERN()
, you could do something like:
#define INCBIN_EXTERN(NAME) \
INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char INCBIN_CONCATENATE(INCBIN_PREFIX, NAME ## Data[]); \
INCBIN_EXTERNAL const INCBIN_ALIGN unsigned char *INCBIN_CONCATENATE(INCBIN_PREFIX, NAME ## End); \
INCBIN_EXTERNAL const unsigned int INCBIN_CONCATENATE(INCBIN_PREFIX, NAME ## Size)
Have tested, does work, it expands NAME too
Actually, my bad, you're right, does not expand the prefix
Fixed
After crosscompiling dnsdist (which uses incbin) for MIPS, using GCC 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r46450 from OpenWRT 15.05 SDK), I noticed that the sizes of INCBIN'ed files are rounded up to the nearest multiple of 4. It seems that the
.balign 1
specified forg<NAME>End
is ignored and those symbols are aligned anyway due to the use of.int
. While my knowledge on this subject is too vague to determine whether it's a compiler bug or not, changing the.int
to.byte
seems to fix the issue on MIPS and, AFAICT, doesn't break any other architecture.