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

Use local labels for inline asm #3451

Closed
okhowang opened this issue Jun 24, 2020 · 6 comments · Fixed by #3452
Closed

Use local labels for inline asm #3451

okhowang opened this issue Jun 24, 2020 · 6 comments · Fixed by #3452
Labels
bug component-crypto Crypto primitives and low-level interfaces

Comments

@okhowang
Copy link
Contributor

Description

  • Type: Bug
  • Priority: Blocker

Bug

OS
iPhoneSimulator

mbed TLS build:
Version: 2.22.0
OS version: 9.0
Configuration: default
Compiler and options (if you used a pre-built binary, please indicate how you obtained it): Xcode 11.5
Additional environment information:

Expected behavior
building success
Actual behavior
got error when linking

<inline asm>:9:2: error: invalid symbol redefinition
        unsupported:              
        ^
LLVM ERROR: Error parsing inline asm

clang: error: linker command failed with exit code 1 (use -v to see invocation)

unsupported: is located in padlock.c which use named labels in inline asm.
Steps to reproduce
I can't make an reproducible minimized project.
but according https://stackoverflow.com/questions/14506151/invalid-symbol-redefinition-in-inline-asm-on-llvm.
we should use local labels for inline asm, not named labels.

@gilles-peskine-arm gilles-peskine-arm added bug component-crypto Crypto primitives and low-level interfaces labels Jun 24, 2020
@gilles-peskine-arm
Copy link
Contributor

What version of Clang is invoked and with what options? I'm asking so that we can try to reproduce this. We have a macOS build on our CI (Clang 9.1.0) that just runs make and it isn't complaining.

@okhowang
Copy link
Contributor Author

$ clang --version
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@okhowang
Copy link
Contributor Author

I add some extra parameter in my project, but i can't reproduce in mbedtls project.

cmake_policy(SET CMP0069 NEW)
cmake_policy(SET CMP0063 NEW)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE YES)

@gilles-peskine-arm
Copy link
Contributor

Maybe set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) turns on link-time optimization and clang decides to inline mbedtls_padlock_has_support in both places where it's called in aes.c. Our CI build doesn't turn on LTO anywhere AFAIR, maybe we should add this. I'll give it a try.

@gilles-peskine-arm
Copy link
Contributor

clang-10 -O3 -flto on Linux doesn't complain. I don't have Clang 11 easily accessible. Can you share the compiler command line that results from these cmake settings?

@okhowang
Copy link
Contributor Author

I'm building iOS library on macOS.
sorry for unable to provide compiler command detailly

okhowang added a commit to okhowang/mbedtls that referenced this issue Jun 26, 2020
Fixes Mbed-TLS#3451

Signed-off-by: okhowang(王沛文) <okhowang@tencent.com>
okhowang added a commit to okhowang/mbedtls that referenced this issue Jul 3, 2020
Fixes Mbed-TLS#3451

Signed-off-by: okhowang(王沛文) <okhowang@tencent.com>
@mpg mpg closed this as completed in #3452 Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-crypto Crypto primitives and low-level interfaces
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants