scripts/glibcelf.py: Add *T_RISCV_* constants

Message ID 87ilq5p7t0.fsf@oldenburg.str.redhat.com
State Committed
Commit d055481ce39d03652ac60de5078889e15b6917ff
Headers
Series scripts/glibcelf.py: Add *T_RISCV_* constants |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Florian Weimer May 16, 2022, 7:59 p.m. UTC
  SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
added in commit 0b6c6750732483b4d59c2fcb45484079cd84157d
("Update RISC-V specific ELF definitions").  This caused the
elf/tst-glibcelf consistency check to fail.

---
 scripts/glibcelf.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Adhemerval Zanella Netto May 16, 2022, 8:05 p.m. UTC | #1
On 16/05/2022 16:59, Florian Weimer via Libc-alpha wrote:
> SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
> added in commit 0b6c6750732483b4d59c2fcb45484079cd84157d
> ("Update RISC-V specific ELF definitions").  This caused the
> elf/tst-glibcelf consistency check to fail.

I was about to investigate it, thanks. Strangely enough, I only saw
the failure for i686 (x86_64 does not show it).

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
> ---
>  scripts/glibcelf.py | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py
> index f847b36c55..07bef94043 100644
> --- a/scripts/glibcelf.py
> +++ b/scripts/glibcelf.py
> @@ -385,6 +385,10 @@ class ShtPARISC(enum.Enum):
>      SHT_PARISC_UNWIND = 0x70000001
>      SHT_PARISC_DOC = 0x70000002
>  
> +class ShtRISCV(enum.Enum):
> +    """Supplemental SHT_* constants for EM_RISCV."""
> +    SHT_RISCV_ATTRIBUTES = 0x70000003
> +
>  class Pf(enum.IntFlag):
>      """Program header flags.  Type of Phdr.p_flags values."""
>      PF_X = 1
> @@ -558,6 +562,10 @@ class PtPARISC(enum.Enum):
>      PT_PARISC_ARCHEXT = 0x70000000
>      PT_PARISC_UNWIND = 0x70000001
>  
> +class PtRISCV(enum.Enum):
> +    """Supplemental PT_* constants for EM_RISCV."""
> +    PT_RISCV_ATTRIBUTES = 0x70000003
> +
>  class Dt(_OpenIntEnum):
>      """ELF dynamic segment tags.  Type of Dyn.d_val."""
>      DT_NULL = 0
> @@ -710,6 +718,10 @@ class DtPPC64(enum.Enum):
>      DT_PPC64_OPDSZ = 0x70000002
>      DT_PPC64_OPT = 0x70000003
>  
> +class DtRISCV(enum.Enum):
> +    """Supplemental DT_* constants for EM_RISCV."""
> +    DT_RISCV_VARIANT_CC = 0x70000001
> +
>  class DtSPARC(enum.Enum):
>      """Supplemental DT_* constants for EM_SPARC."""
>      DT_SPARC_REGISTER = 0x70000001
>
  
Florian Weimer May 16, 2022, 8:23 p.m. UTC | #2
* Adhemerval Zanella via Libc-alpha:

> On 16/05/2022 16:59, Florian Weimer via Libc-alpha wrote:
>> SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
>> added in commit 0b6c6750732483b4d59c2fcb45484079cd84157d
>> ("Update RISC-V specific ELF definitions").  This caused the
>> elf/tst-glibcelf consistency check to fail.
>
> I was about to investigate it, thanks. Strangely enough, I only saw
> the failure for i686 (x86_64 does not show it).

Python version too old?

I guess I have to hand-roll a replacement for the enum module after all.

Thanks for the quick review.

Florian
  
Adhemerval Zanella Netto May 16, 2022, 8:28 p.m. UTC | #3
On 16/05/2022 17:23, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> On 16/05/2022 16:59, Florian Weimer via Libc-alpha wrote:
>>> SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
>>> added in commit 0b6c6750732483b4d59c2fcb45484079cd84157d
>>> ("Update RISC-V specific ELF definitions").  This caused the
>>> elf/tst-glibcelf consistency check to fail.
>>
>> I was about to investigate it, thanks. Strangely enough, I only saw
>> the failure for i686 (x86_64 does not show it).
> 
> Python version too old?

Not sure because I use Python 3.10.4 on both scenarios.

> 
> I guess I have to hand-roll a replacement for the enum module after all.
> 
> Thanks for the quick review.
> 
> Florian
>
  
Florian Weimer May 16, 2022, 8:35 p.m. UTC | #4
* Adhemerval Zanella:

> On 16/05/2022 17:23, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>> 
>>> On 16/05/2022 16:59, Florian Weimer via Libc-alpha wrote:
>>>> SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
>>>> added in commit 0b6c6750732483b4d59c2fcb45484079cd84157d
>>>> ("Update RISC-V specific ELF definitions").  This caused the
>>>> elf/tst-glibcelf consistency check to fail.
>>>
>>> I was about to investigate it, thanks. Strangely enough, I only saw
>>> the failure for i686 (x86_64 does not show it).
>> 
>> Python version too old?
>
> Not sure because I use Python 3.10.4 on both scenarios.

Huh, 3.10 is fine.  And I saw the failure on x86-64 and i386.

Thanks,
Florian
  
Fangrui Song May 16, 2022, 10:41 p.m. UTC | #5
On 2022-05-16, Florian Weimer via Libc-alpha wrote:
>SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
>added in commit 0b6c6750732483b4d59c2fcb45484079cd84157d
>("Update RISC-V specific ELF definitions").  This caused the
>elf/tst-glibcelf consistency check to fail.
>
>---
> scripts/glibcelf.py | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
>diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py
>index f847b36c55..07bef94043 100644
>--- a/scripts/glibcelf.py
>+++ b/scripts/glibcelf.py
>@@ -385,6 +385,10 @@ class ShtPARISC(enum.Enum):
>     SHT_PARISC_UNWIND = 0x70000001
>     SHT_PARISC_DOC = 0x70000002
>
>+class ShtRISCV(enum.Enum):
>+    """Supplemental SHT_* constants for EM_RISCV."""
>+    SHT_RISCV_ATTRIBUTES = 0x70000003
>+
> class Pf(enum.IntFlag):
>     """Program header flags.  Type of Phdr.p_flags values."""
>     PF_X = 1
>@@ -558,6 +562,10 @@ class PtPARISC(enum.Enum):
>     PT_PARISC_ARCHEXT = 0x70000000
>     PT_PARISC_UNWIND = 0x70000001
>
>+class PtRISCV(enum.Enum):
>+    """Supplemental PT_* constants for EM_RISCV."""
>+    PT_RISCV_ATTRIBUTES = 0x70000003
>+
> class Dt(_OpenIntEnum):
>     """ELF dynamic segment tags.  Type of Dyn.d_val."""
>     DT_NULL = 0
>@@ -710,6 +718,10 @@ class DtPPC64(enum.Enum):
>     DT_PPC64_OPDSZ = 0x70000002
>     DT_PPC64_OPT = 0x70000003
>
>+class DtRISCV(enum.Enum):
>+    """Supplemental DT_* constants for EM_RISCV."""
>+    DT_RISCV_VARIANT_CC = 0x70000001
>+
> class DtSPARC(enum.Enum):
>     """Supplemental DT_* constants for EM_SPARC."""
>     DT_SPARC_REGISTER = 0x70000001
>

Thanks for fixing this. I see that I missed

% cat elf/tst-glibcelf.out
error: constant DT_RISCV_VARIANT_CC is missing from glibcelf
error: constant PT_RISCV_ATTRIBUTES is missing from glibcelf
error: constant SHT_RISCV_ATTRIBUTES is missing from glibcelf
note: errors encountered: 3
  

Patch

diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py
index f847b36c55..07bef94043 100644
--- a/scripts/glibcelf.py
+++ b/scripts/glibcelf.py
@@ -385,6 +385,10 @@  class ShtPARISC(enum.Enum):
     SHT_PARISC_UNWIND = 0x70000001
     SHT_PARISC_DOC = 0x70000002
 
+class ShtRISCV(enum.Enum):
+    """Supplemental SHT_* constants for EM_RISCV."""
+    SHT_RISCV_ATTRIBUTES = 0x70000003
+
 class Pf(enum.IntFlag):
     """Program header flags.  Type of Phdr.p_flags values."""
     PF_X = 1
@@ -558,6 +562,10 @@  class PtPARISC(enum.Enum):
     PT_PARISC_ARCHEXT = 0x70000000
     PT_PARISC_UNWIND = 0x70000001
 
+class PtRISCV(enum.Enum):
+    """Supplemental PT_* constants for EM_RISCV."""
+    PT_RISCV_ATTRIBUTES = 0x70000003
+
 class Dt(_OpenIntEnum):
     """ELF dynamic segment tags.  Type of Dyn.d_val."""
     DT_NULL = 0
@@ -710,6 +718,10 @@  class DtPPC64(enum.Enum):
     DT_PPC64_OPDSZ = 0x70000002
     DT_PPC64_OPT = 0x70000003
 
+class DtRISCV(enum.Enum):
+    """Supplemental DT_* constants for EM_RISCV."""
+    DT_RISCV_VARIANT_CC = 0x70000001
+
 class DtSPARC(enum.Enum):
     """Supplemental DT_* constants for EM_SPARC."""
     DT_SPARC_REGISTER = 0x70000001