From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 59AA2384CB97 for ; Thu, 16 May 2024 07:07:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59AA2384CB97 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 59AA2384CB97 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715843278; cv=none; b=IJHKTbzdvZhAHXe4A3XUgA3+rr27Seb+9RLR7zXJgBWgWGfZIvHzulQfjad+/Gmoj3SIwJ3Tb8VnDCgLLojIfiPeJxxVLWqroxgS6j4f6qBYmg4TJ4RoPg68AxtqVcBkDfwX5DwmXdUOEaw0Z8Irqd45ulkX9ze46tuMrvHfa1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715843278; c=relaxed/simple; bh=JyUyvRnGuROlOb6pLtnQZlcCr+wnjOMULtdtdFmbRHE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=gx20dFMae6iOaltjKiKgUdnAJa5G3HzvP/dG0Q9x+H1fXhY6oycMRS3+3bQFDsyio8e0M7N9Tu38KIvU7fQVn8wHrVGS0hjuRloTQtSDmePlrAjRDPprTO8ZzaLNWaSohsnOJSP9+3KWSNKrGA3MIUsStWgisXAlkVhxO26VwPM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-51f74fa2a82so511227e87.0 for ; Thu, 16 May 2024 00:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715843274; x=1716448074; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=x56Nhko0kJNOohP/CYYqbWBs5AqtkGT0kwMjnF+xGfA=; b=DiPwEklcHjVDjs9gD04ZLV3r/AKuH7z6sRkopQEgPUKrlCcIgvS8L+5sYwQWdX5Onn Ru9Jj0mNXNiW/uAJFYiwAFPsBtRhgSg3iaJICwx+ul3powhG1eEjkqjjykkoRkD5fSl+ u0NYg/sdjsXPbohaUU0r4ilPxyeYoa7txMW/BFHJcClOMJApz2JRrYLIAPPTeCfkxcKT +MHnAptvA0SCX/brvMlBZwr4R82fwM5N30UDduDUBARebzJDV4xwdWH2XsDZtlDhbKSx 7TlH1LulJmZQL/YEp85n+5uST9EKAytLtdNEWvnfvKRI/Yu7PnKgvcwx34918ICqWLuT J8Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715843274; x=1716448074; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=x56Nhko0kJNOohP/CYYqbWBs5AqtkGT0kwMjnF+xGfA=; b=kMzWUIA8jKfFT+RFRh7C4yf7ctWoHVE4YALYRboUH30zvTYm8lNgPggKeiEGugUtbl dHy/zH3C8qor13Ym3pmIsgLY7rnKpgnWV5lGxsls78KVFxNsZzsA2UxdA4klpQGlVsao hZHoHBt7RjyqTOV5jGP+i7QhUijgG6eN6O+cTsdHgMAkGlTyCyZFctugPGmRCjTGohxn ZPfzpA6QfCj4GnXAh9I8YQecqk0TweEr4tig1TbSAyAqMvYf8oSJkNQhcsVKiEti7akW A8Eb6UTSyXw7Bagb83rg6NUFCQbDIZpz//BYQcn1xa0LhHKnZ4xQoDelZsw7trhI7gWi kYzQ== X-Gm-Message-State: AOJu0Yw9USkXbqPVR3aIsPApnH313M+i/iLi5Wje19aON5EhyeAa0Rdv eyXsdbSBMtJ07IEf7TP5KS67LccXIIk6nWu8+bUSxN6DpUzm+rbJwdvFI36GShZyvf1iPoHyWNB i+Abmb3iGoov6nuobPsRAJl2W87AXz4sj/VTqZA== X-Google-Smtp-Source: AGHT+IFVJAj19uB7KoVW4eB7jFvcCOhnTY0VDUZ02Jnn+wGuwcL+wsWc4Ndalw2LWLNLATYdlzEDkRa4gWzHRI2VYJw= X-Received: by 2002:a19:2d09:0:b0:523:919d:302e with SMTP id 2adb3069b0e04-523919d325dmr4335587e87.7.1715843273834; Thu, 16 May 2024 00:07:53 -0700 (PDT) MIME-Version: 1.0 References: <20240506044520.2780464-1-hau.hsu@sifive.com> <20240506044520.2780464-2-hau.hsu@sifive.com> <89C7C17E-5E9D-4E00-A3AE-FF1F014C0939@sifive.com> In-Reply-To: <89C7C17E-5E9D-4E00-A3AE-FF1F014C0939@sifive.com> From: Nelson Chu Date: Thu, 16 May 2024 15:07:42 +0800 Message-ID: Subject: Re: [PATCH 2/2] riscv: Fix R_RISCV_IRELATIVE overwrite and order issues To: Hau Hsu Cc: Binutils , Kito Cheng Content-Type: multipart/alternative; boundary="000000000000d3e80606188ce4d4" X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,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: --000000000000d3e80606188ce4d4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 16, 2024 at 2:16=E2=80=AFPM Hau Hsu wrote: > Hi Nelson, > > Sorry for the late reply. > > On May 8, 2024, at 9:00=E2=80=AFAM, Nelson Chu wrot= e: > > Can you provide the testcase to show the case which I mentioned in the > pr13302? Which is that an ifunc with a dynamic jump slot calls another > ifunc, and are not in the rel.dyn. > > I am not quite sure what's the issue you mentioned in PR13302. > You mean the order issue of cause by one ifunc (generates > JUMP_SLOT[32|64]) calls another JUMP_SLOT[32|64] ifunc? > > Since according to the testcase below, it seems no requirement to apply > this fix though. > > The new test case uses two methods to call ifuncs: > 1. Through a normal function call: PLT + GOT > 2. Through a global function pointer: GOT only > > Without the fix, the relocation of the first method overwrites the > second's. > The relocation section of my test case would be: > > Relocation section '.rela.plt' at offset 0x94 contains 2 entries: > Offset Info Type Sym. Value Symbol's Name + Addend > 000110dc 0000003a R_RISCV_IRELATIVE 100c0 > 00000000 00000000 R_RISCV_NONE 0 > > > With the fix, it becomes > > Relocation section '.rela.plt' at offset 0x94 contains 2 entries: > Offset Info Type Sym. Value Symbol's Name + Addend > 000110e0 0000003a R_RISCV_IRELATIVE 100c0 > 000110dc 0000003a R_RISCV_IRELATIVE 100c0 > > So it seems like the overwrite problem, not the order problem we were discussing in the pr13302... > --- /dev/null >> +++ b/ld/testsuite/ld-riscv-elf/ifunc-macro.s >> @@ -0,0 +1,19 @@ >> +/* Define macros to handle similar behaviors for rv32/rv64. >> + Assumes macro "__64_bit__" defined for rv64. >> + The macro is specifically defined for ifunc tests in >> ld-riscv-elf.exp. */ >> + >> +.macro PTR_DATA name >> +.ifdef __64_bit__ >> + .quad \name >> +.else >> + .long \name >> +.endif >> +.endm >> + >> +.macro LOAD rd, rs, offset >> +.ifdef __64_bit__ >> + ld \rd, \offset (\rs) >> +.else >> + lw \rd, \offset (\rs) >> +.endif >> +.endm > > Btw, can we not use these macroes? Nelson --000000000000d3e80606188ce4d4--