Created attachment 9947 [details] errors On elfutils-0.168: # eu-elflint -d $FILE libelf/elf32_getshdr.c:140:8: runtime error: member access within misaligned address 0x7fa161766002 for type 'struct Elf64_Shdr', which requires 8 byte alignment Compiled with: gcc-6.3.0 Visible with: -fsanitize=undefined Reproducer: https://github.com/asarubbo/poc/blob/master/00237-elfutils-misalignedaddress1 Errors attached.
Note that in some cases elfutils deliberately does unaligned accesses if it believes it is safe. See the following in lib/eu-config.h: /* Define ALLOW_UNALIGNED if the architecture allows operations on unaligned memory locations. */ #define SANITIZE_UNDEFINED 1 #if (defined __i386__ || defined __x86_64__) && ! CHECK_UNDEFINED # define ALLOW_UNALIGNED 1 #else # define ALLOW_UNALIGNED 0 #endif Note that it is to not allow unaligned accesses when configuring with --enable-sanitize-undefined (which adds -fsanitize=undefined -fno-sanitize-recover to CFLAGS and CXXFLAGS). Are you configuring using --enable-sanitize-undefined? Or adding -fsanitize=undefined by hand? In the later case you should also add -DCHECK_UNDEFINED=1
(In reply to Mark Wielaard from comment #1) > Note that in some cases elfutils deliberately does unaligned accesses if it > believes it is safe. See the following in lib/eu-config.h: > > /* Define ALLOW_UNALIGNED if the architecture allows operations on > unaligned memory locations. */ > #define SANITIZE_UNDEFINED 1 > #if (defined __i386__ || defined __x86_64__) && ! CHECK_UNDEFINED > # define ALLOW_UNALIGNED 1 > #else > # define ALLOW_UNALIGNED 0 > #endif > > Note that it is to not allow unaligned accesses when configuring with > --enable-sanitize-undefined (which adds -fsanitize=undefined > -fno-sanitize-recover to CFLAGS and CXXFLAGS). > > Are you configuring using --enable-sanitize-undefined? Or adding > -fsanitize=undefined by hand? In the later case you should also add > -DCHECK_UNDEFINED=1 It was added by hand..I need to test if I obtain those warning with --enable-sanitize-undefined
Mark, I do not have enough resources to make again my tests. Let's close this an the other similar report for now, I'll reopen them in the future in case will be needed.
Thanks. Closing for now.