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

ppc64 ELFv2 ABI should not be determined from endianness #8858

Open
q66 opened this issue May 1, 2019 · 9 comments
Open

ppc64 ELFv2 ABI should not be determined from endianness #8858

q66 opened this issue May 1, 2019 · 9 comments
Labels
triaged: feature The issue/pr requests/adds a feature
Milestone

Comments

@q66
Copy link

q66 commented May 1, 2019

The ppc-xlate.pl script currently uses ELFv2 conditionally based on whether the flavor is little endian. This is a pretty common way to check it but it is also incorrect - ELFv2 can also be used on big endian and sometimes is, for example the musl libc uses it unconditionally and it also works with glibc when enabled.

In C, checking for ELFv2 is simple:

$ gcc -dM -E - < /dev/null|grep CALL_ELF
#define _CALL_ELF 2

If the _CALL_ELF macro is defined and set to 2, you are using the ELFv2 ABI. I don't think there is any other reliable way to check, checking for musl in triple disregards other libcs and there is no dedicated target triple for ELFv2. However, I'm not entirely sure what would be the best way to integrate it in openssl. Maybe @dot-asm knows. For now, asm must be disabled in openssl on such targets.

@dot-asm
Copy link
Contributor

dot-asm commented May 5, 2019

First some background information. "perlasm" aims for "least common denominator" among platforms targeted by specific assembly pack. Or in more tangible terms, if question is "why not do something this way, it works for me", then answer is likely to be "it has to work on all systems, even including those that might appear broken to you." I mean there is customarily a reason for why the way things are done looks odd.

Next point, more essential in the context, is "verifiability." In sense that whatever that is supported should be actually verified to work, at least at some point. This is basically why big-endian ELFv2 is not supported, there was no opportunity to verify it. But since opportunity presents itself now, i.e. having you verify it, it's presumably no biggie to add it. So try following:

my %targets = (
    "linux-ppc64v2" => {
        inherit_from  => [ "linux-ppc64" ],
        perlasm_scheme => "linux64v2",
    }
);
  • configure for linux-ppc64v2 with your favourite additional parameters (with exception for no-asm of course);
  • make test;

If it passes, create a merge request...

@q66
Copy link
Author

q66 commented May 5, 2019

Sounds good. I will try and test.

@dot-asm
Copy link
Contributor

dot-asm commented May 5, 2019

In the context of _CALL_ELF compiler pre-define being 2. One can as well say that perlasm_scheme in linux-ppc64 target can be calculated at config time, based on this pre-define, as opposite to be hardcoded that is. But first things first, i.e. does it pass the test?

@q66
Copy link
Author

q66 commented May 5, 2019

I'm not entirely sure when I'll be able to test this, either later today or during the week. Maybe @awilfox could also help test this.

@q66
Copy link
Author

q66 commented May 5, 2019

Actually, I'm running the tests now. I'll have the results in a bit

@q66
Copy link
Author

q66 commented May 5, 2019

Okay! seems fine.

System information (note ppc64 rather than ppc64le):

bash-5.0# uname -a
Linux bevoid 5.0.10_1 #1 SMP Tue Apr 30 10:05:02 UTC 2019 ppc64 GNU/Linux
bash-5.0# grep "^cpu" /proc/cpuinfo|uniq
cpu		: POWER9, altivec supported

OpenSSL build confirmed ELFv2:

bash-5.0# readelf -h libcrypto.so.3|grep Flags
  Flags:                             0x2, abiv2

GCC confirmed emitting ELFv2:

bash-5.0# gcc -dM -E - < /dev/null|grep CALL_ELF
#define _CALL_ELF 2

Configdata dump:

bash-5.0# perl configdata.pm --dump

Command line (with current working directory = .):

    /usr/bin/perl ../Configure linux-ppc64v2 --libdir=lib --openssldir=/etc/ssl

Perl information:

    /usr/bin/perl
    5.28.1 for powerpc64-linux

Enabled features:

    afalgeng
    aria
    asm
    async
    autoalginit
    autoerrinit
    autoload-config
    bf
    blake2
    camellia
    capieng
    cast
    chacha
    cmac
    cms
    comp
    crmf
    ct
    deprecated
    des
    dgram
    dh
    dsa
    dtls
    dynamic-engine
    ec
    ec2m
    ecdh
    ecdsa
    engine
    err
    filenames
    fips
    gost
    idea
    legacy
    makedepend
    md4
    mdc2
    module
    multiblock
    nextprotoneg
    pinshared
    ocb
    ocsp
    padlockeng
    pic
    poly1305
    posix-io
    psk
    rc2
    rc4
    rdrand
    rfc3779
    rmd160
    scrypt
    seed
    shared
    siphash
    siv
    sm2
    sm3
    sm4
    sock
    srp
    srtp
    sse2
    ssl
    static-engine
    stdio
    tests
    threads
    tls
    ts
    ui-console
    whirlpool
    tls1
    tls1-method
    tls1_1
    tls1_1-method
    tls1_2
    tls1_2-method
    tls1_3
    dtls1
    dtls1-method
    dtls1_2
    dtls1_2-method

Disabled features:

    ktls                    [default] OPENSSL_NO_KTLS
    asan                    [default] OPENSSL_NO_ASAN
    buildtest-c++           [default] 
    crypto-mdebug           [default] OPENSSL_NO_CRYPTO_MDEBUG
    crypto-mdebug-backtrace [default] OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
    devcryptoeng            [default] OPENSSL_NO_DEVCRYPTOENG
    ec_nistp_64_gcc_128     [default] OPENSSL_NO_EC_NISTP_64_GCC_128
    egd                     [default] OPENSSL_NO_EGD
    external-tests          [default] OPENSSL_NO_EXTERNAL_TESTS
    fuzz-libfuzzer          [default] OPENSSL_NO_FUZZ_LIBFUZZER
    fuzz-afl                [default] OPENSSL_NO_FUZZ_AFL
    md2                     [default] OPENSSL_NO_MD2 (skip crypto/md2)
    msan                    [default] OPENSSL_NO_MSAN
    rc5                     [default] OPENSSL_NO_RC5 (skip crypto/rc5)
    sctp                    [default] OPENSSL_NO_SCTP
    ssl-trace               [default] OPENSSL_NO_SSL_TRACE
    trace                   [default] OPENSSL_NO_TRACE
    ubsan                   [default] OPENSSL_NO_UBSAN
    unit-test               [default] OPENSSL_NO_UNIT_TEST
    weak-ssl-ciphers        [default] OPENSSL_NO_WEAK_SSL_CIPHERS
    zlib                    [default] 
    zlib-dynamic            [default] 
    ssl3                    [default] OPENSSL_NO_SSL3
    ssl3-method             [default] OPENSSL_NO_SSL3_METHOD

Config target attributes:

    AR => "ar",
    ARFLAGS => "r",
    CC => "gcc",
    CFLAGS => "-Wall -O3",
    CXX => "g++",
    CXXFLAGS => "-Wall -O3",
    HASHBANGPERL => "/usr/bin/env perl",
    RANLIB => "ranlib",
    RC => "windres",
    aes_asm_src => "aes_core.c aes_cbc.c aes-ppc.s vpaes-ppc.s aesp8-ppc.s",
    aes_obj => "aes_core.o aes_cbc.o aes-ppc.o vpaes-ppc.o aesp8-ppc.o",
    apps_aux_src => "",
    apps_init_src => "",
    apps_obj => "",
    bf_asm_src => "bf_enc.c",
    bf_obj => "bf_enc.o",
    bn_asm_src => "bn-ppc.s ppc-mont.s",
    bn_obj => "bn-ppc.o ppc-mont.o",
    bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
    build_file => "Makefile",
    build_scheme => [ "unified", "unix" ],
    cast_asm_src => "c_enc.c",
    cast_obj => "c_enc.o",
    cflags => "-pthread -m64",
    chacha_asm_src => "chacha-ppc.s",
    chacha_obj => "chacha-ppc.o",
    cmll_asm_src => "camellia.c cmll_misc.c cmll_cbc.c",
    cmll_obj => "camellia.o cmll_misc.o cmll_cbc.o",
    cppflags => "",
    cpuid_asm_src => "ppccpuid.s ppccap.c",
    cpuid_obj => "ppccpuid.o ppccap.o",
    cxxflags => "-std=c++11 -pthread -m64",
    defines => [  ],
    des_asm_src => "des_enc.c fcrypt_b.c",
    des_obj => "des_enc.o fcrypt_b.o",
    disable => [  ],
    dso_ldflags => "-z defs",
    dso_scheme => "dlfcn",
    ec_asm_src => "ecp_nistz256.c ecp_nistz256-ppc64.s x25519-ppc64.s",
    ec_obj => "ecp_nistz256.o ecp_nistz256-ppc64.o x25519-ppc64.o",
    enable => [ "afalgeng" ],
    ex_libs => "-ldl -pthread",
    includes => [  ],
    keccak1600_asm_src => "keccak1600-ppc64.s",
    keccak1600_obj => "keccak1600-ppc64.o",
    lflags => "",
    lib_cflags => "",
    lib_cppflags => "-DOPENSSL_USE_NODELETE -DB_ENDIAN",
    lib_defines => [  ],
    md5_asm_src => "",
    md5_obj => "",
    modes_asm_src => "ghashp8-ppc.s",
    modes_obj => "ghashp8-ppc.o",
    module_cflags => "-fPIC",
    module_cxxflags => "",
    module_ldflags => "-Wl,-znodelete -shared -Wl,-Bsymbolic",
    multilib => "64",
    padlock_asm_src => "",
    padlock_obj => "",
    perl_platform => "Unix",
    perlasm_scheme => "linux64v2",
    poly1305_asm_src => "poly1305-ppc.s poly1305-ppcfp.s",
    poly1305_obj => "poly1305-ppc.o poly1305-ppcfp.o",
    rc4_asm_src => "rc4_enc.c rc4_skey.c",
    rc4_obj => "rc4_enc.o rc4_skey.o",
    rc5_asm_src => "rc5_enc.c",
    rc5_obj => "rc5_enc.o",
    rmd160_asm_src => "",
    rmd160_obj => "",
    sha1_asm_src => "sha1-ppc.s sha256-ppc.s sha512-ppc.s sha256p8-ppc.s sha512p8-ppc.s",
    sha1_obj => "sha1-ppc.o sha256-ppc.o sha512-ppc.o sha256p8-ppc.o sha512p8-ppc.o",
    shared_cflag => "-fPIC",
    shared_defflag => "-Wl,--version-script=",
    shared_defines => [  ],
    shared_ldflag => "-Wl,-znodelete -shared -Wl,-Bsymbolic",
    shared_rcflag => "",
    shared_sonameflag => "-Wl,-soname=",
    shared_target => "linux-shared",
    thread_defines => [  ],
    thread_scheme => "pthreads",
    unistd => "<unistd.h>",
    uplink_aux_src => "",
    uplink_obj => "",
    wp_asm_src => "wp_block.c",
    wp_obj => "wp_block.o",

Recorded environment:

    AR = 
    ARFLAGS = 
    AS = 
    ASFLAGS = 
    BUILDFILE = 
    CC = 
    CFLAGS = 
    CPP = 
    CPPDEFINES = 
    CPPFLAGS = 
    CPPINCLUDES = 
    CROSS_COMPILE = 
    CXX = 
    CXXFLAGS = 
    HASHBANGPERL = 
    LD = 
    LDFLAGS = 
    LDLIBS = 
    MT = 
    MTFLAGS = 
    OPENSSL_LOCAL_CONFIG_DIR = 
    PERL = 
    RANLIB = 
    RC = 
    RCFLAGS = 
    RM = 
    WINDRES = 
    __CNF_CFLAGS = 
    __CNF_CPPDEFINES = 
    __CNF_CPPFLAGS = 
    __CNF_CPPINCLUDES = 
    __CNF_CXXFLAGS = 
    __CNF_LDFLAGS = 
    __CNF_LDLIBS = 

Makevars:

    AR              = ar
    ARFLAGS         = r
    CC              = gcc
    CFLAGS          = -Wall -O3
    CPPDEFINES      = 
    CPPFLAGS        = 
    CPPINCLUDES     = 
    CXX             = g++
    CXXFLAGS        = -Wall -O3
    HASHBANGPERL    = /usr/bin/env perl
    LDFLAGS         = 
    LDLIBS          = 
    PERL            = /usr/bin/perl
    RANLIB          = ranlib
    RC              = windres
    RCFLAGS         = 

NOTE: These variables only represent the configuration view.  The build file
template may have processed these variables further, please have a look at the
build file for more exact data:
    Makefile

build file:

    Makefile

build file templates:

    ../Configurations/common0.tmpl
    ../Configurations/unix-Makefile.tmpl
    ../Configurations/common.tmpl

Finally, tests passing:

bash-5.0# make test
make depend && make _tests
make[1]: Entering directory '/root/openssl/build'
make[1]: Leaving directory '/root/openssl/build'
make[1]: Entering directory '/root/openssl/build'
( cd test; \
  mkdir -p test-runs; \
  SRCTOP=../.. \
  BLDTOP=../. \
  RESULT_D=test-runs \
  PERL="/usr/bin/perl" \
  EXE_EXT= \
  OPENSSL_ENGINES=`cd .././engines 2>/dev/null && pwd` \
  OPENSSL_DEBUG_MEMORY=on \
    /usr/bin/perl ../../test/run_tests.pl  )
../../test/recipes/01-test_abort.t .................... ok   
../../test/recipes/01-test_sanity.t ................... ok   
../../test/recipes/01-test_symbol_presence.t .......... ok   
../../test/recipes/01-test_test.t ..................... ok   
../../test/recipes/02-test_errstr.t ................... ok     
../../test/recipes/02-test_internal_context.t ......... ok   
../../test/recipes/02-test_internal_ctype.t ........... ok   
../../test/recipes/02-test_internal_provider.t ........ ok   
../../test/recipes/02-test_lhash.t .................... ok   
../../test/recipes/02-test_ordinals.t ................. ok   
../../test/recipes/02-test_sparse_array.t ............. ok   
../../test/recipes/02-test_stack.t .................... ok   
../../test/recipes/03-test_exdata.t ................... ok   
../../test/recipes/03-test_internal_asn1.t ............ ok   
../../test/recipes/03-test_internal_bn.t .............. ok   
../../test/recipes/03-test_internal_chacha.t .......... ok   
../../test/recipes/03-test_internal_curve448.t ........ ok   
../../test/recipes/03-test_internal_ec.t .............. ok   
../../test/recipes/03-test_internal_mdc2.t ............ ok   
../../test/recipes/03-test_internal_modes.t ........... ok   
../../test/recipes/03-test_internal_poly1305.t ........ ok   
../../test/recipes/03-test_internal_rsa_sp800_56b.t ... ok   
../../test/recipes/03-test_internal_siphash.t ......... ok   
../../test/recipes/03-test_internal_sm2.t ............. ok   
../../test/recipes/03-test_internal_sm4.t ............. ok   
../../test/recipes/03-test_internal_ssl_cert_table.t .. ok   
../../test/recipes/03-test_internal_x509.t ............ ok   
../../test/recipes/03-test_params_api.t ............... ok   
../../test/recipes/03-test_property.t ................. ok   
../../test/recipes/03-test_ui.t ....................... ok   
../../test/recipes/04-test_asn1_decode.t .............. ok   
../../test/recipes/04-test_asn1_encode.t .............. ok   
../../test/recipes/04-test_asn1_string_table.t ........ ok   
../../test/recipes/04-test_bio_callback.t ............. ok   
../../test/recipes/04-test_bioprint.t ................. ok   
../../test/recipes/04-test_err.t ...................... ok   
../../test/recipes/04-test_params.t ................... ok   
../../test/recipes/04-test_pem.t ...................... ok     
../../test/recipes/04-test_provider.t ................. ok   
../../test/recipes/05-test_bf.t ....................... ok   
../../test/recipes/05-test_cast.t ..................... ok   
../../test/recipes/05-test_des.t ...................... ok   
../../test/recipes/05-test_hmac.t ..................... ok   
../../test/recipes/05-test_idea.t ..................... ok   
../../test/recipes/05-test_md2.t ...................... skipped: md2 is not supported by this OpenSSL build
../../test/recipes/05-test_mdc2.t ..................... ok   
../../test/recipes/05-test_rand.t ..................... ok   
../../test/recipes/05-test_rc2.t ...................... ok   
../../test/recipes/05-test_rc4.t ...................... ok   
../../test/recipes/05-test_rc5.t ...................... skipped: rc5 is not supported by this OpenSSL build
../../test/recipes/06-test-rdrand.t ................... ok   
../../test/recipes/10-test_bn.t ....................... ok   
../../test/recipes/10-test_exp.t ...................... ok   
../../test/recipes/15-test_dh.t ....................... ok   
../../test/recipes/15-test_dsa.t ...................... ok   
../../test/recipes/15-test_ec.t ....................... ok   
../../test/recipes/15-test_ecdsa.t .................... ok   
../../test/recipes/15-test_ecparam.t .................. ok       
../../test/recipes/15-test_genrsa.t ................... ok   
../../test/recipes/15-test_mp_rsa.t ................... ok     
../../test/recipes/15-test_out_option.t ............... ok   
../../test/recipes/15-test_rsa.t ...................... ok   
../../test/recipes/15-test_rsapss.t ................... ok   
../../test/recipes/20-test_enc.t ...................... ok       
../../test/recipes/20-test_enc_more.t ................. ok       
../../test/recipes/20-test_kdf.t ...................... ok   
../../test/recipes/20-test_mac.t ...................... ok     
../../test/recipes/20-test_passwd.t ................... ok     
../../test/recipes/20-test_pkeyutl.t .................. ok   
../../test/recipes/25-test_crl.t ...................... ok   
../../test/recipes/25-test_d2i.t ...................... ok     
../../test/recipes/25-test_pkcs7.t .................... ok   
../../test/recipes/25-test_req.t ...................... ok   
../../test/recipes/25-test_sid.t ...................... ok   
../../test/recipes/25-test_verify.t ................... ok       
../../test/recipes/25-test_x509.t ..................... ok     
../../test/recipes/30-test_aesgcm.t ................... ok   
../../test/recipes/30-test_afalg.t .................... ok   
../../test/recipes/30-test_engine.t ................... ok   
../../test/recipes/30-test_evp.t ...................... ok     
../../test/recipes/30-test_evp_extra.t ................ ok   
../../test/recipes/30-test_evp_kdf.t .................. ok   
../../test/recipes/30-test_pbelu.t .................... ok   
../../test/recipes/30-test_pkey_meth.t ................ ok   
../../test/recipes/30-test_pkey_meth_kdf.t ............ ok   
../../test/recipes/40-test_rehash.t ................... ok   
../../test/recipes/60-test_x509_check_cert_pkey.t ..... ok   
../../test/recipes/60-test_x509_dup_cert.t ............ ok   
../../test/recipes/60-test_x509_store.t ............... ok   
../../test/recipes/60-test_x509_time.t ................ ok   
../../test/recipes/70-test_asyncio.t .................. ok   
../../test/recipes/70-test_bad_dtls.t ................. ok   
../../test/recipes/70-test_clienthello.t .............. ok   
../../test/recipes/70-test_comp.t ..................... ok   
../../test/recipes/70-test_key_share.t ................ ok    
../../test/recipes/70-test_packet.t ................... ok   
../../test/recipes/70-test_recordlen.t ................ ok   
../../test/recipes/70-test_renegotiation.t ............ ok   
../../test/recipes/70-test_servername.t ............... ok   
../../test/recipes/70-test_sslcbcpadding.t ............ ok   
../../test/recipes/70-test_sslcertstatus.t ............ ok   
../../test/recipes/70-test_sslextension.t ............. ok   
../../test/recipes/70-test_sslmessages.t .............. ok    
../../test/recipes/70-test_sslrecords.t ............... ok    
../../test/recipes/70-test_sslsessiontick.t ........... ok    
../../test/recipes/70-test_sslsigalgs.t ............... ok    
../../test/recipes/70-test_sslsignature.t ............. ok   
../../test/recipes/70-test_sslskewith0p.t ............. ok   
../../test/recipes/70-test_sslversions.t .............. ok   
../../test/recipes/70-test_sslvertol.t ................ ok   
../../test/recipes/70-test_tls13alerts.t .............. ok   
../../test/recipes/70-test_tls13cookie.t .............. ok   
../../test/recipes/70-test_tls13downgrade.t ........... ok   
../../test/recipes/70-test_tls13hrr.t ................. ok   
../../test/recipes/70-test_tls13kexmodes.t ............ ok    
../../test/recipes/70-test_tls13messages.t ............ ok    
../../test/recipes/70-test_tls13psk.t ................. ok   
../../test/recipes/70-test_tlsextms.t ................. ok    
../../test/recipes/70-test_verify_extra.t ............. ok   
../../test/recipes/70-test_wpacket.t .................. ok   
../../test/recipes/80-test_ca.t ....................... ok   
../../test/recipes/80-test_cipherbytes.t .............. ok   
../../test/recipes/80-test_cipherlist.t ............... ok   
../../test/recipes/80-test_ciphername.t ............... ok   
../../test/recipes/80-test_cms.t ...................... ok   
../../test/recipes/80-test_cmsapi.t ................... ok   
../../test/recipes/80-test_ct.t ....................... ok   
../../test/recipes/80-test_dane.t ..................... ok   
../../test/recipes/80-test_dtls.t ..................... ok   
../../test/recipes/80-test_dtls_mtu.t ................. ok   
../../test/recipes/80-test_dtlsv1listen.t ............. ok   
../../test/recipes/80-test_ocsp.t ..................... ok     
../../test/recipes/80-test_pkcs12.t ................... ok   
../../test/recipes/80-test_ssl_new.t .................. ok     
../../test/recipes/80-test_ssl_old.t .................. ok   
../../test/recipes/80-test_ssl_test_ctx.t ............. ok   
../../test/recipes/80-test_sslcorrupt.t ............... ok   
../../test/recipes/80-test_tsa.t ...................... ok     
../../test/recipes/80-test_x509aux.t .................. ok   
../../test/recipes/90-test_asn1_time.t ................ ok   
../../test/recipes/90-test_async.t .................... ok   
../../test/recipes/90-test_bio_enc.t .................. ok   
../../test/recipes/90-test_bio_memleak.t .............. ok   
../../test/recipes/90-test_constant_time.t ............ ok   
../../test/recipes/90-test_fatalerr.t ................. ok   
../../test/recipes/90-test_gmdiff.t ................... ok   
../../test/recipes/90-test_gost.t ..................... skipped: No test GOST engine found
../../test/recipes/90-test_ige.t ...................... ok   
../../test/recipes/90-test_includes.t ................. ok   
../../test/recipes/90-test_memleak.t .................. ok   
../../test/recipes/90-test_overhead.t ................. skipped: Only supported in no-shared builds
../../test/recipes/90-test_secmem.t ................... ok   
../../test/recipes/90-test_shlibload.t ................ ok     
../../test/recipes/90-test_srp.t ...................... ok   
../../test/recipes/90-test_sslapi.t ................... ok   
../../test/recipes/90-test_sslbuffers.t ............... ok   
../../test/recipes/90-test_store.t .................... ok       
../../test/recipes/90-test_sysdefault.t ............... ok   
../../test/recipes/90-test_threads.t .................. ok   
../../test/recipes/90-test_time_offset.t .............. ok   
../../test/recipes/90-test_tls13ccs.t ................. ok   
../../test/recipes/90-test_tls13encryption.t .......... ok   
../../test/recipes/90-test_tls13secrets.t ............. ok   
../../test/recipes/90-test_v3name.t ................... ok   
../../test/recipes/95-test_external_boringssl.t ....... skipped: No external tests in this configuration
../../test/recipes/95-test_external_krb5.t ............ skipped: No external tests in this configuration
../../test/recipes/95-test_external_pyca.t ............ skipped: No external tests in this configuration
../../test/recipes/99-test_ecstress.t ................. ok   
../../test/recipes/99-test_fuzz.t ..................... ok     
All tests successful.
Files=169, Tests=1636, 133 wallclock secs ( 2.09 usr  0.14 sys + 137.13 cusr  4.95 csys = 144.31 CPU)
Result: PASS

@q66
Copy link
Author

q66 commented May 5, 2019

Anyway, I think it'd be best to modify the ppc64-linux configuration to check for _CALL_ELF and set the appropriate perlasm scheme according to that. The logic should be something like, if _CALL_ELF is defined and its value is 2, use ELFv2, otherwise if it's undefined or its value is anything else, use ELFv1. I didn't need to do anything else other than apply your patch for ppc-xlate.pl and make it use the appropriate perlasm_scheme.

What would be considered the best way to check for the macro in the configurations system?

@dot-asm
Copy link
Contributor

dot-asm commented May 6, 2019

Ideally one would appreciate possibility to assign sub { $predefined_C{_CALL_ELF} == 2 ? "linux64v2" : "linux64 } to perlasm_scheme, but there is chicken-n-egg problem. I mean by the time the sub is executed, %predefined_C is not instantiated. But there is "Platform fix-ups" section, so something like this would be appropriate and should do the job:

index 701368d..1091eb3 100755
--- a/Configure
+++ b/Configure
@@ -1378,6 +1378,11 @@ unless ($disabled{"fuzz-libfuzzer"} && $disabled{"fuzz-afl"}
 # Platform fix-ups
 #
 
+my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
+my %predefined_CXX = $config{CXX}
+    ? compiler_predefined($config{CROSS_COMPILE}.$config{CXX})
+    : ();
+
 # This saves the build files from having to check
 if ($disabled{pic})
         {
@@ -1466,13 +1471,11 @@ unless ($disabled{asm}) {
     if ($target{poly1305_asm_src} ne "") {
         push @{$config{lib_defines}}, "POLY1305_ASM";
     }
+    if ($target eq "linux-ppc64") {
+        $target{perlasm_scheme} = "linux64v2" if ($predefined_C{_CALL_ELF} == 2);
+    }
 }
 
-my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
-my %predefined_CXX = $config{CXX}
-    ? compiler_predefined($config{CROSS_COMPILE}.$config{CXX})
-    : ();
-
 # Check for makedepend capabilities.
 if (!$disabled{makedepend}) {
     if ($config{target} =~ /^(VC|vms)-/) {

@q66
Copy link
Author

q66 commented May 6, 2019

Okay, I thought I could query the compiler from a perlasm_scheme => sub { } directly in the configuration (I saw this done for windows) but this should also work.

All tests successful.
Files=169, Tests=1636, 131 wallclock secs ( 2.15 usr  0.11 sys + 132.23 cusr  4.84 csys = 139.33 CPU)
Result: PASS
make[1]: Leaving directory '/root/openssl/build'
bash-5.0# perl configdata.pm --dump|grep perlasm
    perlasm_scheme => "linux64v2",

@mattcaswell mattcaswell added the triaged: feature The issue/pr requests/adds a feature label Nov 19, 2019
@t8m t8m added this to the Post 3.0.0 milestone Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged: feature The issue/pr requests/adds a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants