Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 2.28: bn_mul.h: fix x86 PIC inline ASM compilation with GCC < 5 #6096

Commits on Jul 19, 2022

  1. bn_mul.h: fix x86 PIC inline ASM compilation with GCC < 5

    Fixes Mbed-TLS#1910
    
    With ebx added to the MULADDC_STOP clobber list to fix Mbed-TLS#1550, the inline
    assembly fails to build with GCC < 5 in PIC mode with the following error:
    
    include/mbedtls/bn_mul.h:46:13: error: PIC register clobbered by ‘ebx’ in ‘asm’
    
    This is because older GCC versions treated the x86 ebx register (which is
    used for the GOT) as a fixed reserved register when building as PIC.
    
    This is fixed by an improved register allocator in GCC 5+.  From the release
    notes:
    
    Register allocation improvements: Reuse of the PIC hard register, instead of
    using a fixed register, was implemented on x86/x86-64 targets.  This
    improves generated PIC code performance as more hard registers can be used.
    
    https://www.gnu.org/software/gcc/gcc-5/changes.html
    
    As a workaround, detect this situation and disable the inline assembly,
    similar to the MULADDC_CANNOT_USE_R7 logic.
    
    Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
    jacmet authored and tom-cosgrove-arm committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    9d9d45c View commit details
    Browse the repository at this point in the history
  2. Add a ChangeLog entry

    Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
    tom-cosgrove-arm committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    accd50d View commit details
    Browse the repository at this point in the history