[PATCH v3] elf: Set p_align to the minimum page size if possible
Jan Beulich
jbeulich@suse.com
Fri Jan 14 08:12:44 GMT 2022
On 29.12.2021 20:39, H.J. Lu via Binutils wrote:
> --- /dev/null
> +++ b/ld/testsuite/ld-elf/p_align-1.c
> @@ -0,0 +1,25 @@
> +#include <stdio.h>
> +#include <stdint.h>
> +#include <stdlib.h>
> +
> +#ifndef ALIGN
> +# define ALIGN 0x800000
> +#endif
> +
> +int
> +__attribute__ ((weak))
> +is_aligned (void *p, int align)
> +{
> + return (((uintptr_t) p) & (align - 1)) == 0;
> +}
> +
> +int foo __attribute__ ((aligned (ALIGN))) = 1;
Alongside newer distros I also continue to build and test binutils on an
oldish one. gcc 4.3 looks to silently ignore[1] alignment values larger
than 1Mb on at least 32-bit x86. Hence all 4 derived tests fail there. I
think you want to verify that foo's alignment is actually 8Mb in the
object file, or use an assembler source instead of a C one (albeit I can
see that this would undermine your PIE / non-PIE test variants).
Jan
[1] It's actually worse than "ignore": The variable gets no alignment at
all then, not even the expected 4-byte one.
More information about the Binutils
mailing list