Hi Scott, thanks for having a look.
On Mon, Nov 28, 2022 at 03:14:59PM +0000, Scott Ashcroft wrote: > I've done some work on why the mips64el build fails. > The issue is that the test script tests/sat/grom.ys makes yosys core in > libs/fst/fstapi.cc:fstGetUint32 > > Looking at the code it is clear that, when FST_DO_MISALIGNED_OPS is not > defined, an address on the stack is returned to calling function. I'm not sure what you mean here, my reading of the code is that it's just tring to read a big-endian uint32_t at the given address regardless of alignment. No address is returned. > Because the Debian build uses various hardening flags to protect > accesses to the stack that makes a segfault. While the code is indeed a bit iffy TBH I don't really see why it should crash even with the stack protector etc. enabled. Regardless if you still have a test environment could you try the attached patch that turns the roundabout u8 to u32 conversion into a (hopefully) more portable roundtrip through a union. --Daniel
--- a/libs/fst/fstapi.cc +++ b/libs/fst/fstapi.cc @@ -348,17 +348,17 @@ static void *fstMmap2(size_t __len, int #ifdef FST_DO_MISALIGNED_OPS #define fstGetUint32(x) (*(uint32_t *)(x)) #else -static uint32_t fstGetUint32(unsigned char *mem) +static inline uint32_t fstGetUint32(unsigned char *mem) { - uint32_t u32; - unsigned char *buf = (unsigned char *)(&u32); + union { + uint8_t u8[sizeof(uint32_t)]; + uint32_t u32; + } u; - buf[0] = mem[0]; - buf[1] = mem[1]; - buf[2] = mem[2]; - buf[3] = mem[3]; + for (int i=0; i < sizeof(u.u8); i++) + u.u8[i] = mem[i]; - return (*(uint32_t *)buf); + return u.u32; } #endif