embench / embench-iot

The main Embench repository
https://www.embench.org/
GNU General Public License v3.0
259 stars 104 forks source link

Tarfind isn't portable due to assuming struct layout #186

Open widlarizer opened 1 year ago

widlarizer commented 1 year ago

/* 8995 = sizeof(tar_header_t) * ARCHIVE_FILES */ followed by a hard-coded 8995 demonstrates that the source assumes the amount of padding an ABI will do. For Infineon TriCore, this does not hold. EABI v1.3 says: "To facilitate copy operations, any structure larger than 1 Byte must have a minimum 2 Byte alignment, even if its only members are byte elements.".

PaoloS02 commented 8 months ago

Thanks for this. I'll mark this as a bug until we are able to verify it, but it seems that what you are describing is indeed a limitation to portability.

jeremybennett commented 8 months ago

Add @I-mikan-I since this may be relevant to Embench IoT 2.0

I-mikan-I commented 8 months ago

Seems to be the case, 8bec9db fixes this by simply calculating the size in a macro, and also using c11 alignment specifiers.