[PATCH] ld/x86: skip p_align-1 tests with unsuitable compiler
H.J. Lu
hjl.tools@gmail.com
Mon Jun 27 13:04:42 GMT 2022
On Mon, Jun 27, 2022 at 2:07 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> When the compiler doesn't properly arrange for foo's alignment, there's
> no point even trying these tests. Report the situation as a single
> "unsupported" test.
> ---
> While I don't think ld testcases should be used to detect compiler (or
> kernel) regressions, it might be an option to make the filter less
> strict and bypass the tests only when .data's alignment is actually 1.
>
> Note that this still leaves unaddressed the other fallout from the
> introduction of these tests, requiring a relatively modern (Oct 2020 or
> newer) kernel. Would be nice if this was also addressed for 2.39 (it was
> bad enough that 2.38 was shipped this way), but I for one can't see any
> easy / straightforward way for probing the kernel.
>
> --- a/ld/testsuite/ld-elf/linux-x86.exp
> +++ b/ld/testsuite/ld-elf/linux-x86.exp
> @@ -185,44 +185,54 @@ run_ld_link_exec_tests [list \
> "" \
> "tmpdir/indirect-extern-access-2.so" \
> ] \
> - [list \
> - "Run p_align-1a without PIE" \
> - "$NOPIE_LDFLAGS" \
> - "" \
> - { p_align-1.c } \
> - "p_align-1a" \
> - "pass.out" \
> - "$NOPIE_CFLAGS" \
> - ] \
> - [list \
> - "Run p_align-1b with PIE" \
> - "-pie" \
> - "" \
> - { p_align-1.c } \
> - "p_align-1b" \
> - "pass.out" \
> - "-fpie" \
> - ] \
> - [list \
> - "Run p_align-1c with -Wl,-z,max-page-size=0x1000 without PIE" \
> - "$NOPIE_LDFLAGS -Wl,-z,max-page-size=0x1000" \
> - "" \
> - { p_align-1.c } \
> - "p_align-1c" \
> - "pass.out" \
> - "$NOPIE_CFLAGS" \
> - ] \
> - [list \
> - "Run p_align-1d with -Wl,-z,max-page-size=0x1000 with PIE" \
> - "-pie -Wl,-z,max-page-size=0x1000" \
> - "" \
> - { p_align-1.c } \
> - "p_align-1d" \
> - "pass.out" \
> - "-fpie" \
> - ] \
> ]
>
> +# Old gcc silently ignores __attribute__ ((aligned())) with too big alignment.
> +ld_compile $CC_FOR_TARGET $srcdir/$subdir/p_align-1.c tmpdir/p_align-1.o
> +set output [run_host_cmd "$READELF" "-SW tmpdir/p_align-1.o"]
> +if { [regexp { [.]data *PROGBITS .* 8388608[\n]} $output] } then {
> + run_ld_link_exec_tests [list \
> + [list \
> + "Run p_align-1a without PIE" \
> + "$NOPIE_LDFLAGS" \
> + "" \
> + { p_align-1.c } \
> + "p_align-1a" \
> + "pass.out" \
> + "$NOPIE_CFLAGS" \
> + ] \
> + [list \
> + "Run p_align-1b with PIE" \
> + "-pie" \
> + "" \
> + { p_align-1.c } \
> + "p_align-1b" \
> + "pass.out" \
> + "-fpie" \
> + ] \
> + [list \
> + "Run p_align-1c with -Wl,-z,max-page-size=0x1000 without PIE" \
> + "$NOPIE_LDFLAGS -Wl,-z,max-page-size=0x1000" \
> + "" \
> + { p_align-1.c } \
> + "p_align-1c" \
> + "pass.out" \
> + "$NOPIE_CFLAGS" \
> + ] \
> + [list \
> + "Run p_align-1d with -Wl,-z,max-page-size=0x1000 with PIE" \
> + "-pie -Wl,-z,max-page-size=0x1000" \
> + "" \
> + { p_align-1.c } \
> + "p_align-1d" \
> + "pass.out" \
> + "-fpie" \
> + ] \
> + ]
> +} else {
> + unsupported "p_align-1"
> +}
> +
> proc elfedit_test { options test output } {
> global ELFEDIT
> global READELF
OK.
Thanks.
--
H.J.
More information about the Binutils
mailing list