From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 3785A3857373 for ; Wed, 20 Apr 2022 16:47:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3785A3857373 Received: by mail-oi1-x233.google.com with SMTP id r85so2688342oie.7 for ; Wed, 20 Apr 2022 09:47:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=Q6oXjl7y3hn/oCD4amTDySWQEsArZKUZ+c6pFqil5to=; b=oG/sgDzarTl15B7knm0uREacKm8fiaEBgFmx/A8ZgabhBoK7ZW86pJaHOf9srSZgIc zTIngXpOwhDdEQ0qXxbM6n2PL6uYyzsJh0PSru8lNfwXIDJdgj6rsC3yV6nRxTGEnIZ2 RbnHaxh9GCdQrsMhHDlSjR1QoxJCzXgh99a5uDWWYCAdjterV4r7rp5jB4Rf5QklifHh 8puSRRW7kYNoT8pUx4XIfCwttCXdDvas60H0TJpv8wPg7quOzRzfdWslHLf5xOLf5R0d 9jLAJgP/9MXYIKNDd6k92rvwhNC9y2BrJ8INb2rmSqnVdzk9pWT8nokRDP0DaiUcx6oe /I1Q== X-Gm-Message-State: AOAM532BlS2yseKaUNKS9XHjFfydOCdkJAhBlqRQtXW6t88/vT/I/xWX M0u/1aXsA+QXZyLTsDOmChDfrXxMNFGDoA== X-Google-Smtp-Source: ABdhPJxYe+95tGvDMEDy0mOMQIg101InxUfD3YOw4AJnjTLp0qYoo3IPxdMSrdPxH5gIg6RGUCeadQ== X-Received: by 2002:a05:6808:144a:b0:2ef:9fa2:ba7f with SMTP id x10-20020a056808144a00b002ef9fa2ba7fmr2129221oiv.88.1650473274418; Wed, 20 Apr 2022 09:47:54 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:c9d0:24b1:bd98:2ef4:714c? ([2804:431:c7ca:c9d0:24b1:bd98:2ef4:714c]) by smtp.gmail.com with ESMTPSA id 9-20020a9d0289000000b005e8f77e3022sm6678505otl.57.2022.04.20.09.47.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Apr 2022 09:47:53 -0700 (PDT) Message-ID: Date: Wed, 20 Apr 2022 13:47:51 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] m68k: Handle fewer relocations for RTLD_BOOTSTRAP (#BZ29071) Content-Language: en-US To: Fangrui Song , libc-alpha@sourceware.org, Andreas Schwab References: <20220420023532.367055-1-maskray@google.com> From: Adhemerval Zanella In-Reply-To: <20220420023532.367055-1-maskray@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2022 16:47:57 -0000 On 19/04/2022 23:35, Fangrui Song wrote: > m68k is a non-PI_STATIC_AND_HIDDEN arch which uses a GOT relocation when > loading a jump table. The GOT load may be reordered before processing > R_68K_RELATIVE relocations, leading to an unrelocated/incorrect jump > table. The foolproof approach is to add an optimization barrier (e.g. > calling a function after relative relocations are resolved). That isn't > suitable given the current code structure, so just use the simple > approach to avoid the jump table: handle only the essential reloctions > for RTLD_BOOTSTRAP code. > > This is based on Andreas Schwab's patch and fixed ld.so crash on m68k. LGTM, thanks. The loader does not triggers a segfault anymore. Reviewed-by: Adhemerval Zanella > --- > sysdeps/m68k/dl-machine.h | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h > index c44ab055aa..bb51b4198c 100644 > --- a/sysdeps/m68k/dl-machine.h > +++ b/sysdeps/m68k/dl-machine.h > @@ -234,6 +234,11 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], > > switch (r_type) > { > + case R_68K_GLOB_DAT: > + case R_68K_JMP_SLOT: > + *reloc_addr = value; > + break; > +#ifndef RTLD_BOOTSTRAP > case R_68K_COPY: > if (sym == NULL) > /* This can happen in trace mode if an object could not be > @@ -252,10 +257,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], > memcpy (reloc_addr_arg, (void *) value, > MIN (sym->st_size, refsym->st_size)); > break; > - case R_68K_GLOB_DAT: > - case R_68K_JMP_SLOT: > - *reloc_addr = value; > - break; > case R_68K_8: > *(char *) reloc_addr = value + reloc->r_addend; > break; > @@ -276,7 +277,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], > case R_68K_PC32: > *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr; > break; > -#ifndef RTLD_BOOTSTRAP > case R_68K_TLS_DTPMOD32: > /* Get the information from the link map returned by the > resolv function. */ > @@ -294,9 +294,9 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], > *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc); > } > break; > -#endif /* !RTLD_BOOTSTRAP */ > case R_68K_NONE: /* Alright, Wilbur. */ > break; > +#endif /* !RTLD_BOOTSTRAP */ > default: > _dl_reloc_bad_type (map, r_type, 0); > break;