From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 38B3E3858D37 for ; Tue, 3 Jan 2023 12:09:09 +0000 (GMT) Received: by mail-oi1-x22e.google.com with SMTP id u204so26441944oib.7 for ; Tue, 03 Jan 2023 04:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=O0v2iDvw+Nu6P+kRMTZt6G0yUS3VrJoCxKofLdkDRzo=; b=l/gXv8T7lGH9F2K5BAEyX9mEnPAtMxM1fckGC7AQGf451inRFBdNY+he8aJ+FpxAcl FMyic1Dyta1bLFyPGlWHtgKKKZJykNYAJ8MtvKo1Xc0ycy0f3QE4w8+ejzH4cMXsLege PMJFJvKOiJU8xgQKbHiJdHhCaO+fijaLJbNAaNWemWWzFsAElPTI4hmyA+YcPrGo+1mY 2iFMJs5J2QvPczPy8w5WeJCtdzS1WfVvaK7R9HfLnUGfdxy0ass//AskRDZRzibYaGjO 2Q+f8Ig2GkIFDyOQS1E/UbIue9GP38T6pU95D+3jx34mf9t4b3Rqtt0cKbFadpfDclUk AMEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=O0v2iDvw+Nu6P+kRMTZt6G0yUS3VrJoCxKofLdkDRzo=; b=o2PKfWMmbvJn0V0D5/Da19nLHEPd60U/xdoCu134J9sPflnRK4EPuZ2UgdisIdPX4N KhvWlUJKIZ1pFxFWFXdoXCUV9JzMY3/FaGBuQS5UOassNmnX32IrivhfWQwLGxfN5nHc C0IEVbngrGQZnvv3EUCqY4UApuBeAxo3sp7fZ2y+sIRCWPKtGuYpEop8stjfouRCFmhX Y92VNLFe6+ZHyvUM4ni2hvsBMDHX0d0wQ/fgl1I9V/yXT9NjMkctW0ziFXmnmQL6y6ET iAVSYJVtLwZJzrzy1IEIyWr1sz4AUJoAYN3E1OqG5JXKcjYNUmjbotcW80paZ6Bi2Uyh m8eg== X-Gm-Message-State: AFqh2kqY4HhLoS5ns8WxOkBFLI2yWsjqyJ60VdhlU25CMlmJeeZ0hRBh 98yf7pYMLsKBHf/9ryRnr4KZQQ== X-Google-Smtp-Source: AMrXdXt3wRPgFmyO6GniYykD+pQzcXOLm0bX1CwSQdahClVlQXhUWdEPjYkZfMjNtGg3i1R/8nHilw== X-Received: by 2002:a05:6808:2898:b0:35e:13d2:ac2f with SMTP id eu24-20020a056808289800b0035e13d2ac2fmr18432128oib.8.1672747747808; Tue, 03 Jan 2023 04:09:07 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:1729:54db:2a30:ff9e:ffaa? ([2804:1b3:a7c0:1729:54db:2a30:ff9e:ffaa]) by smtp.gmail.com with ESMTPSA id q43-20020a056830442b00b006393ea22c1csm14782596otv.16.2023.01.03.04.09.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 04:09:07 -0800 (PST) Message-ID: <86f86d4e-b9d5-1caf-a5ac-018bb95b38bc@linaro.org> Date: Tue, 3 Jan 2023 09:09:04 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Update on the glibc segfault issue on Alpha Content-Language: en-US To: John Paul Adrian Glaubitz , "debian-alpha@lists.debian.org" Cc: gentoo-alpha@lists.gentoo.org, GNU C Library , Florian Weimer References: <999879fc-9cb3-1efa-165b-36a5418f2e41@physik.fu-berlin.de> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 02/01/23 14:37, John Paul Adrian Glaubitz wrote: > Hello! > > On 1/2/23 12:44, John Paul Adrian Glaubitz wrote: >> Adhemerval from glibc upstream is aware of the problem but he has not found yet a solution >> to this issue as it needs to be debugged further. I will try to bisect which particular >> introduced the regression and file a new upstream bug report. >> >> During our discussion, Adhemerval pointed out that this change [3] might be the culprit >> but I have not been able to verify this yet. > > My latest bisecting has shown this change to be the responsible change, CC'ing the author: > > commit 73fc4e28b9464f0e13edc719a5372839970e7ddb (refs/bisect/bad) > Author: Florian Weimer > Date:   Mon Feb 28 11:50:41 2022 +0100 > >     Linux: Consolidate auxiliary vector parsing (redo) >         And optimize it slightly. >         This is commit 8c8510ab2790039e58995ef3a22309582413d3ff revised. >         In _dl_aux_init in elf/dl-support.c, use an explicit loop >     and -fno-tree-loop-distribute-patterns to avoid memset. >         Reviewed-by: Szabolcs Nagy Thanks, this commits helps narrow down the issue. The 73fc4e28b9464f0e refactor did not add the GL(dl_phdr) and GL(dl_phnum) for static case, relying on the __ehdr_start symbol to get the correct values. The issue is for some archs, alpha for instance, the hidden weak reference is not making the static linker to define the __ehdr_start address correctly: it is being set to 0 and thus GL(dl_phdr) and GL(dl_phnum) are set to invalid values. And I am not sure if the hidden weak __ehdr_start does work on all architectures, so I think it would be safer to just restore the previous behavior to setup GL(dl_phdr) and GL(dl_phnum) for static and we can simplify __ehdr_start fallback case to not use a weak ref (as for PIE). I am checking if the following patch trigger any regression, at least for alpha it fixes the static failures: diff --git a/csu/libc-start.c b/csu/libc-start.c index 543560f36c..63a3eceaea 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -271,18 +271,10 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), So we can set up _dl_phdr and _dl_phnum even without any information from auxv. */ - extern const ElfW(Ehdr) __ehdr_start -# if BUILD_PIE_DEFAULT - __attribute__ ((visibility ("hidden"))); -# else - __attribute__ ((weak, visibility ("hidden"))); - if (&__ehdr_start != NULL) -# endif - { - assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); - GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; - GL(dl_phnum) = __ehdr_start.e_phnum; - } + extern const ElfW(Ehdr) __ehdr_start attribute_hidden; + assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); + GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; + GL(dl_phnum) = __ehdr_start.e_phnum; } __tunables_init (__environ); diff --git a/sysdeps/unix/sysv/linux/dl-parse_auxv.h b/sysdeps/unix/sysv/linux/dl-parse_auxv.h index bf9374371e..5913c9d6e5 100644 --- a/sysdeps/unix/sysv/linux/dl-parse_auxv.h +++ b/sysdeps/unix/sysv/linux/dl-parse_auxv.h @@ -56,6 +56,10 @@ void _dl_parse_auxv (ElfW(auxv_t) *av, dl_parse_auxv_t auxv_values) if (GLRO(dl_sysinfo_dso) != NULL) GLRO(dl_sysinfo) = auxv_values[AT_SYSINFO]; #endif +#ifndef SHARED + GL(dl_phdr) = (void*) auxv_values[AT_PHDR]; + GL(dl_phnum) = auxv_values[AT_PHENT]; +#endif DL_PLATFORM_AUXV }