From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 498D03858423 for ; Tue, 17 Oct 2023 04:46:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 498D03858423 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 498D03858423 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697518009; cv=none; b=OBSm5NeYh00LlNUqKVe0mIg1ZuXX49jTvUxOhgCb3ShPDPxrfh1F1jcZMRo0wdgL5OEkejPsoAMLQI/Jw6XHYZx0xdt+ooVXNWQuURRFriVZD0n3aFfkaK4Ht8bLPnLNiIL8ACtK1YGvdU8y2DbGpxpege2llBFcsi7SW4kvgAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697518009; c=relaxed/simple; bh=X/zHIw/nVT/H6wAeoD5+QGF3/cr2LevVl635QQv3/NI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=NUhwZnjdayu5KoMuT/FG0y0GmAU2mX0K8FOCDwrvNLp2hEcR8boyDo9wpsqF1imqZev+zToFYD1hBPJW7pUjk8ilrUAKQnw9PbmFvo2CYXZxMqitOe7wp9ZEoqB4z4d/a7y7iNK7zVy9hdx+jlzlQXWr4vRZYpOoU9qaK+oYZXo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c9c145bb5bso88745ad.1 for ; Mon, 16 Oct 2023 21:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697518006; x=1698122806; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bOKdWKeb1igWcW9WGagyu2YVflA6ozzCnyBusJTa3Os=; b=glbutE4UNBUkFbweDIoGrHuM7oDGyXIPpBwHUw6yVqQxlYYMh/F35Uz1jJ0tBKXdTA beJCTWenOxNpxGMk99RWe4VhjZz519s84OYsTy9GBNQow1M6GaEvykuh24Y92ANW6hND OHqRDjmevMBCch0G6CLHjrJ2l7RQYzECjhT0T8G1UsTVbrnk/cox1ihwKVv2kTwAwphb XptPzKcAwX5wANHkT+hkNi6m/lszxRk3H8neLHL6DDTT5AwSYZqO6iWelLTtBvrrwiSs 76MUMr7TGv7MY/8mSJquKLn59uVqZbsfb2SSwdrhMw/0cxkJq9MVP6PaEFSbq+KUwrD3 vTHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697518006; x=1698122806; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bOKdWKeb1igWcW9WGagyu2YVflA6ozzCnyBusJTa3Os=; b=JlmVLLrn22X4TrJ6/pUt2JXQq21Nq742T9sqVHe2m4Adi7MVX+vPWLNnD8k44dO7Cr iv1p5+o8zfo1PAws1rwFLjU/Xq23mvHq30Zz+H4cEiqgs3hgWqpZYSfeBdy2bH2OsHEl rbK3rq3x3bC6fYchxDOl9T36gSUr+QeRNi8Wut1K2oIJFOsKeO4ju5cYJ/VkukyzhCn6 g2je0+1A58giOIas/e+WuOGZEMRP+HJsxdeJ10HRqo/L2NqtNoettr9xL1AF9BA0I9d2 OTzX6op2XNT5+Txp0Udwgw3MGRK/pl9n2Jy4CfmGQESY/N4NP4yyXSlK/Bji0T+zNI1c NUwg== X-Gm-Message-State: AOJu0YyRXamFwv8KM1aiYabs6AqfzdL6og7voxmE7D4bQa88ymu7c4xn QxyIKYHDbJOg2k+AXWjkOIXUVA== X-Google-Smtp-Source: AGHT+IHN69boNsM2jmllu3EhAqrQOBImbqH/T48PG6Efq0c7Jk124I3vW3eAkddxBccf7Es6TIqvPw== X-Received: by 2002:a17:902:f70c:b0:1c4:1392:e4b5 with SMTP id h12-20020a170902f70c00b001c41392e4b5mr92679plo.21.1697518005956; Mon, 16 Oct 2023 21:46:45 -0700 (PDT) Received: from google.com ([2620:15c:2d3:205:1972:b984:359b:c069]) by smtp.gmail.com with ESMTPSA id rj6-20020a17090b3e8600b0027782f611d1sm5312473pjb.36.2023.10.16.21.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 21:46:45 -0700 (PDT) Date: Mon, 16 Oct 2023 21:46:41 -0700 From: Fangrui Song To: Florian Weimer Cc: Jessica Clarke , Evan Green , libc-alpha@sourceware.org, slewis@rivosinc.com, vineetg@rivosinc.com, palmer@rivosinc.com Subject: Re: [PATCH v8 3/6] riscv: Add __riscv_hwprobe pointer to ifunc calls Message-ID: <20231017044641.pw2ccr6exvhtmhkk@google.com> References: <20230901235224.3304592-1-evan@rivosinc.com> <20230901235224.3304592-4-evan@rivosinc.com> <87v8bszs20.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <87v8bszs20.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-20.2 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no 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 2023-09-29, Florian Weimer wrote: >* Jessica Clarke: > >> Being able to write portable IFUNC resolvers across Linux, BSDs and >> other similar OSes is valuable, and this would preclude that. In FreeBSD >> there are no issues with calling functions from IFUNC resolvers; we just >> process all non-IRELATIVE relocations before IRELATIVE ones. > >Even across multiple objects? In glibc, we rely on relocation order by >the link editor to put IRELATIVE last, so we don't have that particular >problem for IRELATIVE, but we have it for regular symbol-based >relocations that happen to refer to IFUNC symbols because the relocation >order my not reflect the symbol binding order. > >Thanks, >Florian As a resolution to https://sourceware.org/bugzilla/show_bug.cgi?id=13302 ("IRELATIVE relocation should come last"), GNU ld places IRELATIVE in .rela.plt (strange, as IRELATIVE is not lazy). I think relyong on this is too brittle, as IRELATIVE may be in .rela.dyn . I have just filed https://sourceware.org/bugzilla/show_bug.cgi?id=30976 ("rtld: resolve ifunc relocations after JUMP_SLOT/GLOB_DAT/etc") based on my examples at https://maskray.me/blog/2021-01-18-gnu-indirect-function#relocation-resolving-order FreeBSD rtld uses multiple phases and in my analysis > The approach turns out to be very robust. Many segfault examples on > glibc work on FreeBSD. glibc rtld probably does not need to do so much. Just refactoring the loop in elf/dynamic-link.h so that IRELATIVE, regardless of .rela.dyn or .rela.plt, will work for my examples. Then the outcome will look good enough to me. for (int ranges_index = 0; ranges_index < 2; ++ranges_index)