From: Palmer Dabbelt <palmer@rivosinc.com>
To: yanzhang.wang@intel.com
Cc: libc-alpha@sourceware.org, schwab@suse.de, adhemerval.zanella@linaro.org
Subject: RE: [PATCH] RISC-V: Fix the static-PIE non-relocated object check
Date: Thu, 22 Feb 2024 19:06:58 -0800 (PST) [thread overview]
Message-ID: <mhng-6f02a9dd-a12e-4791-9c73-d848a395a02a@palmer-ri-x1c9a> (raw)
In-Reply-To: <IA1PR11MB646644DCF5B5DB91EB13CD2AF2552@IA1PR11MB6466.namprd11.prod.outlook.com>
On Thu, 22 Feb 2024 18:16:47 PST (-0800), yanzhang.wang@intel.com wrote:
> Hi Palmer,
>
> Thanks for your patch. I have did the full tests with the same change
> as this patch on my qemu-system. There's no regression introduced.
>
> Also test this change with mold linker. It passed.
Awesome, thanks. I don't have a good setup for this so I was sort of
just trying to figure it out from poking aroud the code and whatever
Andres said.
Are you OK posting a Tested-by? This will probably get backported, so
best to get that stuff sorted out.
>
> Thanks,
> Yanzhang
>
>> -----Original Message-----
>> From: Palmer Dabbelt <palmer@rivosinc.com>
>> Sent: Friday, February 23, 2024 7:24 AM
>> To: libc-alpha@sourceware.org
>> Cc: schwab@suse.de; Wang, Yanzhang <yanzhang.wang@intel.com>;
>> adhemerval.zanella@linaro.org; Palmer Dabbelt <palmer@rivosinc.com>
>> Subject: [PATCH] RISC-V: Fix the static-PIE non-relocated object check
>>
>> The value of l_scope is only valid post relocation, so this original check
>> was triggering undefined behavior. Instead just directly check to see if
>> the object has been relocated, at which point using l_scope is safe.
>>
>> Reported-by: Andreas Schwab <schwab@suse.de>
>> Closes: BZ #31317
>> Fixes: e0590f41fe ("RISC-V: Enable static-pie.")
>> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
>> ---
>> sysdeps/riscv/dl-machine.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h index
>> 0cbb476c05..b2f28697f7 100644
>> --- a/sysdeps/riscv/dl-machine.h
>> +++ b/sysdeps/riscv/dl-machine.h
>> @@ -348,7 +348,7 @@ elf_machine_runtime_setup (struct link_map *l, struct
>> r_scope_elem *scope[],
>> gotplt[1] = (ElfW(Addr)) l;
>> }
>>
>> - if (l->l_type == lt_executable && l->l_scope != NULL)
>> + if (l->l_type == lt_executable && l->l_relocated)
>> {
>> /* The __global_pointer$ may not be defined by the linker if the
>> $gp register does not be used to access the global variable
>> --
>> 2.43.0
next prev parent reply other threads:[~2024-02-23 3:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 23:24 Palmer Dabbelt
2024-02-23 2:16 ` Wang, Yanzhang
2024-02-23 3:06 ` Palmer Dabbelt [this message]
2024-02-23 3:47 ` Wang, Yanzhang
2024-02-29 9:11 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mhng-6f02a9dd-a12e-4791-9c73-d848a395a02a@palmer-ri-x1c9a \
--to=palmer@rivosinc.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=schwab@suse.de \
--cc=yanzhang.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).