From 35f2d9adc43b22cf9493077efcffbabec229dbb6 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Fri, 17 May 2024 21:31:58 +0200 Subject: [PATCH] zehn_loader: Tell the compiler that the malloced header is aligned It doesn't know that the function call returns an aligned pointer, so tell it explicitly. This way it uses aligned loads instead of multiple byte loads. Here the size goes from 616 to 484, saving more than 20%! --- ndless-sdk/tools/zehn_loader/loader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndless-sdk/tools/zehn_loader/loader.cpp b/ndless-sdk/tools/zehn_loader/loader.cpp index cab4ce7e..a87bef6e 100644 --- a/ndless-sdk/tools/zehn_loader/loader.cpp +++ b/ndless-sdk/tools/zehn_loader/loader.cpp @@ -72,9 +72,9 @@ int main(int argc, char **argv) old_storage = reinterpret_cast(header); syscall(mallocd, old_storage, header->file_size); - header = reinterpret_cast(mallocd); + header = reinterpret_cast(__builtin_assume_aligned(mallocd, 4)); } - + const Zehn_reloc *reloc_table = reinterpret_cast(reinterpret_cast(header) + sizeof(Zehn_header)); //This loader doesn't parse the flag table const uint8_t *flag_table = reinterpret_cast(reloc_table) + sizeof(Zehn_reloc) * header->reloc_count;