* [musl] [PATCH v2] Define user_regs, elf_greg_t and elf_fpregset_t for or1k
@ 2022-05-17 21:58 Florian Fainelli
2022-05-19 4:18 ` [musl] " Stafford Horne
0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2022-05-17 21:58 UTC (permalink / raw)
To: musl
Cc: dalias, thomas.petazzoni, stefan.kristiansson, shorne, Florian Fainelli
The OpenRISC architecture is currently missing a definition of its
user_regs structure, elf_greg_t and elf_fpregset_t as well as ELF_NGREG,
add those.
---
Changes in v2:
- Follow Stafford's recommendations based upon glibc
arch/or1k/bits/user.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/or1k/bits/user.h b/arch/or1k/bits/user.h
index e69de29bb2d1..227f022e2fec 100644
--- a/arch/or1k/bits/user.h
+++ b/arch/or1k/bits/user.h
@@ -0,0 +1,10 @@
+struct user_regs {
+ unsigned long gpr[32];
+ unsigned long pc;
+ unsigned long sr;
+};
+
+#define ELF_NGREG 32
+typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
+
+typedef elf_greg_t elf_fpregset_t[ELF_NGREG];
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [musl] Re: [PATCH v2] Define user_regs, elf_greg_t and elf_fpregset_t for or1k
2022-05-17 21:58 [musl] [PATCH v2] Define user_regs, elf_greg_t and elf_fpregset_t for or1k Florian Fainelli
@ 2022-05-19 4:18 ` Stafford Horne
2022-05-19 21:29 ` Florian Fainelli
0 siblings, 1 reply; 3+ messages in thread
From: Stafford Horne @ 2022-05-19 4:18 UTC (permalink / raw)
To: Florian Fainelli; +Cc: musl, dalias, thomas.petazzoni, stefan.kristiansson
On Tue, May 17, 2022 at 02:58:26PM -0700, Florian Fainelli wrote:
> The OpenRISC architecture is currently missing a definition of its
> user_regs structure, elf_greg_t and elf_fpregset_t as well as ELF_NGREG,
> add those.
> ---
> Changes in v2:
>
> - Follow Stafford's recommendations based upon glibc
>
> arch/or1k/bits/user.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/or1k/bits/user.h b/arch/or1k/bits/user.h
> index e69de29bb2d1..227f022e2fec 100644
> --- a/arch/or1k/bits/user.h
> +++ b/arch/or1k/bits/user.h
> @@ -0,0 +1,10 @@
> +struct user_regs {
> + unsigned long gpr[32];
> + unsigned long pc;
> + unsigned long sr;
> +};
> +
> +#define ELF_NGREG 32
> +typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
> +
I think ELF_NGREG should be 34 here.
On glibc we defined this like this, but I am beginning to doubt it is correct:
(sys/ucontext.h)
#define __NGREG 32
(bits/procfs.h)
#define ELF_NGREG __NGREG
typedef elf_greg_t elf_gregset_t[34];
In linux and some other architectures they define ELF_NGREG as below (so that
would mean 34 is right):
#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
In linux we define this, so yours matches.
(arch/openrisc/include/uapi/asm/ptrace.h)
truct user_regs_struct {
/* GPR R0-R31... */
unsigned long gpr[32];
unsigned long pc;
unsigned long sr;
};
> +typedef elf_greg_t elf_fpregset_t[ELF_NGREG];
This should be:
typedef elf_greg_t elf_fpregset_t[32];
However, I have tested all of glibc with the definition as above with ELF_NGREG
32 and elf_gregset_t[34]. But, I think I will like to change that and test
again.
So in the end I think we should use this.
#define ELF_NGREG (sizeof (struct user_regs) / sizeof (elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
typedef elf_greg_t elf_fpregset_t[32];
Side Point
I am not sure why cpulimit needs elf_gregset_t anyway. I see it includes
procfs.h, I removed that include and it seems to compile ok.
-Stafford
^ permalink raw reply [flat|nested] 3+ messages in thread
* [musl] Re: [PATCH v2] Define user_regs, elf_greg_t and elf_fpregset_t for or1k
2022-05-19 4:18 ` [musl] " Stafford Horne
@ 2022-05-19 21:29 ` Florian Fainelli
0 siblings, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2022-05-19 21:29 UTC (permalink / raw)
To: Stafford Horne; +Cc: musl, dalias, thomas.petazzoni, stefan.kristiansson
On 5/18/2022 9:18 PM, Stafford Horne wrote:
> On Tue, May 17, 2022 at 02:58:26PM -0700, Florian Fainelli wrote:
>> The OpenRISC architecture is currently missing a definition of its
>> user_regs structure, elf_greg_t and elf_fpregset_t as well as ELF_NGREG,
>> add those.
>> ---
>> Changes in v2:
>>
>> - Follow Stafford's recommendations based upon glibc
>>
>> arch/or1k/bits/user.h | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/arch/or1k/bits/user.h b/arch/or1k/bits/user.h
>> index e69de29bb2d1..227f022e2fec 100644
>> --- a/arch/or1k/bits/user.h
>> +++ b/arch/or1k/bits/user.h
>> @@ -0,0 +1,10 @@
>> +struct user_regs {
>> + unsigned long gpr[32];
>> + unsigned long pc;
>> + unsigned long sr;
>> +};
>> +
>> +#define ELF_NGREG 32
>> +typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
>> +
>
> I think ELF_NGREG should be 34 here.
>
> On glibc we defined this like this, but I am beginning to doubt it is correct:
>
> (sys/ucontext.h)
> #define __NGREG 32
>
> (bits/procfs.h)
> #define ELF_NGREG __NGREG
> typedef elf_greg_t elf_gregset_t[34];
>
> In linux and some other architectures they define ELF_NGREG as below (so that
> would mean 34 is right):
>
> #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
>
> In linux we define this, so yours matches.
>
> (arch/openrisc/include/uapi/asm/ptrace.h)
> truct user_regs_struct {
> /* GPR R0-R31... */
> unsigned long gpr[32];
> unsigned long pc;
> unsigned long sr;
> };
>
>> +typedef elf_greg_t elf_fpregset_t[ELF_NGREG];
>
> This should be:
>
> typedef elf_greg_t elf_fpregset_t[32];
>
> However, I have tested all of glibc with the definition as above with ELF_NGREG
> 32 and elf_gregset_t[34]. But, I think I will like to change that and test
> again.
>
> So in the end I think we should use this.
>
> #define ELF_NGREG (sizeof (struct user_regs) / sizeof (elf_greg_t))
> typedef elf_greg_t elf_gregset_t[ELF_NGREG];
> typedef elf_greg_t elf_fpregset_t[32];
OK, thanks!
>
>
> Side Point
>
> I am not sure why cpulimit needs elf_gregset_t anyway. I see it includes
> procfs.h, I removed that include and it seems to compile ok.
Yes, I think there must have been some confusion that procfs.h might be
related to manipulating the /proc filesystem on Linux when it is not. I
will submit a patch to buildroot backporting the pull request:
https://github.com/opsengine/cpulimit/pull/110
Thanks!
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-05-19 21:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 21:58 [musl] [PATCH v2] Define user_regs, elf_greg_t and elf_fpregset_t for or1k Florian Fainelli
2022-05-19 4:18 ` [musl] " Stafford Horne
2022-05-19 21:29 ` Florian Fainelli
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).