[03/17] Add support for the RISC-V-specific ELF flags

Message ID 20180125043621.19972-4-palmer@dabbelt.com
State New, archived
Headers

Commit Message

Palmer Dabbelt Jan. 25, 2018, 4:36 a.m. UTC
  The RISC-V port defines ELF flags that enforce compatibility between
various objects.  This adds the shared support necessary for these
flags.

2018-01-13  Palmer Dabbelt  <palmer@sifive.com>

        * elf/cache.c (print_entry): Add FLAG_RISCV_FLOAT_ABI_SOFT and
        FLAG_RISCV_FLOAT_ABI_DOUBLE.
        * elf/elf.h (EF_RISCV_RVC): New define.
        (EF_RISCV_FLOAT_ABI): Likewise.
        (EF_RISCV_FLOAT_ABI_SOFT): Likewise.
        (EF_RISCV_FLOAT_ABI_SINGLE): Likewise.
        (EF_RISCV_FLOAT_ABI_DOUBLE): Likewise.
        (EF_RISCV_FLOAT_ABI_QUAD): Likewise.
        * sysdeps/generic/ldconfig.h (FLAG_RISCV_FLOAT_ABI_SOFT): New
        define.
        (FLAG_RISCV_FLOAT_ABI_DOUBLE): Likewise.
---
 elf/cache.c                | 6 ++++++
 elf/elf.h                  | 8 ++++++++
 sysdeps/generic/ldconfig.h | 2 ++
 3 files changed, 16 insertions(+)
  

Comments

Joseph Myers Jan. 25, 2018, 4:51 p.m. UTC | #1
On Wed, 24 Jan 2018, Palmer Dabbelt wrote:

> The RISC-V port defines ELF flags that enforce compatibility between
> various objects.  This adds the shared support necessary for these
> flags.
> 
> 2018-01-13  Palmer Dabbelt  <palmer@sifive.com>
> 
>         * elf/cache.c (print_entry): Add FLAG_RISCV_FLOAT_ABI_SOFT and
>         FLAG_RISCV_FLOAT_ABI_DOUBLE.
>         * elf/elf.h (EF_RISCV_RVC): New define.
>         (EF_RISCV_FLOAT_ABI): Likewise.
>         (EF_RISCV_FLOAT_ABI_SOFT): Likewise.
>         (EF_RISCV_FLOAT_ABI_SINGLE): Likewise.
>         (EF_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>         (EF_RISCV_FLOAT_ABI_QUAD): Likewise.
>         * sysdeps/generic/ldconfig.h (FLAG_RISCV_FLOAT_ABI_SOFT): New
>         define.
>         (FLAG_RISCV_FLOAT_ABI_DOUBLE): Likewise.

This patch is OK, please commit.
  
Palmer Dabbelt Jan. 25, 2018, 6:09 p.m. UTC | #2
On Thu, 25 Jan 2018 08:51:05 PST (-0800), joseph@codesourcery.com wrote:
> On Wed, 24 Jan 2018, Palmer Dabbelt wrote:
>
>> The RISC-V port defines ELF flags that enforce compatibility between
>> various objects.  This adds the shared support necessary for these
>> flags.
>>
>> 2018-01-13  Palmer Dabbelt  <palmer@sifive.com>
>>
>>         * elf/cache.c (print_entry): Add FLAG_RISCV_FLOAT_ABI_SOFT and
>>         FLAG_RISCV_FLOAT_ABI_DOUBLE.
>>         * elf/elf.h (EF_RISCV_RVC): New define.
>>         (EF_RISCV_FLOAT_ABI): Likewise.
>>         (EF_RISCV_FLOAT_ABI_SOFT): Likewise.
>>         (EF_RISCV_FLOAT_ABI_SINGLE): Likewise.
>>         (EF_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>>         (EF_RISCV_FLOAT_ABI_QUAD): Likewise.
>>         * sysdeps/generic/ldconfig.h (FLAG_RISCV_FLOAT_ABI_SOFT): New
>>         define.
>>         (FLAG_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>
> This patch is OK, please commit.

Thanks.  Committed!
  
Szabolcs Nagy Jan. 26, 2018, 3:49 p.m. UTC | #3
On 25/01/18 18:09, Palmer Dabbelt wrote:
> On Thu, 25 Jan 2018 08:51:05 PST (-0800), joseph@codesourcery.com wrote:
>> On Wed, 24 Jan 2018, Palmer Dabbelt wrote:
>>
>>> The RISC-V port defines ELF flags that enforce compatibility between
>>> various objects.  This adds the shared support necessary for these
>>> flags.
>>>
>>> 2018-01-13  Palmer Dabbelt  <palmer@sifive.com>
>>>
>>>         * elf/cache.c (print_entry): Add FLAG_RISCV_FLOAT_ABI_SOFT and
>>>         FLAG_RISCV_FLOAT_ABI_DOUBLE.
>>>         * elf/elf.h (EF_RISCV_RVC): New define.
>>>         (EF_RISCV_FLOAT_ABI): Likewise.
>>>         (EF_RISCV_FLOAT_ABI_SOFT): Likewise.
>>>         (EF_RISCV_FLOAT_ABI_SINGLE): Likewise.
>>>         (EF_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>>>         (EF_RISCV_FLOAT_ABI_QUAD): Likewise.
>>>         * sysdeps/generic/ldconfig.h (FLAG_RISCV_FLOAT_ABI_SOFT): New
>>>         define.
>>>         (FLAG_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>>
>> This patch is OK, please commit.
> 
> Thanks.  Committed!

note that the FLAG_RISCV_FLOAT_ABI_SOFT ldconfig.h macro
value conflicts with the arm/ilp32 branch, i can update this
in the ilp32 branch but ldconfig will print existing ilp32
ld.so.cache files incorrectly.
  
Palmer Dabbelt Jan. 26, 2018, 5:51 p.m. UTC | #4
On Fri, 26 Jan 2018 07:49:44 PST (-0800), szabolcs.nagy@arm.com wrote:
> On 25/01/18 18:09, Palmer Dabbelt wrote:
>> On Thu, 25 Jan 2018 08:51:05 PST (-0800), joseph@codesourcery.com wrote:
>>> On Wed, 24 Jan 2018, Palmer Dabbelt wrote:
>>>
>>>> The RISC-V port defines ELF flags that enforce compatibility between
>>>> various objects.  This adds the shared support necessary for these
>>>> flags.
>>>>
>>>> 2018-01-13  Palmer Dabbelt  <palmer@sifive.com>
>>>>
>>>>         * elf/cache.c (print_entry): Add FLAG_RISCV_FLOAT_ABI_SOFT and
>>>>         FLAG_RISCV_FLOAT_ABI_DOUBLE.
>>>>         * elf/elf.h (EF_RISCV_RVC): New define.
>>>>         (EF_RISCV_FLOAT_ABI): Likewise.
>>>>         (EF_RISCV_FLOAT_ABI_SOFT): Likewise.
>>>>         (EF_RISCV_FLOAT_ABI_SINGLE): Likewise.
>>>>         (EF_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>>>>         (EF_RISCV_FLOAT_ABI_QUAD): Likewise.
>>>>         * sysdeps/generic/ldconfig.h (FLAG_RISCV_FLOAT_ABI_SOFT): New
>>>>         define.
>>>>         (FLAG_RISCV_FLOAT_ABI_DOUBLE): Likewise.
>>>
>>> This patch is OK, please commit.
>>
>> Thanks.  Committed!
>
> note that the FLAG_RISCV_FLOAT_ABI_SOFT ldconfig.h macro
> value conflicts with the arm/ilp32 branch, i can update this
> in the ilp32 branch but ldconfig will print existing ilp32
> ld.so.cache files incorrectly.

Oh, sorry about that.  I don't mind changing our flag value, what should I make 
it?
  
Joseph Myers Jan. 26, 2018, 6 p.m. UTC | #5
On Fri, 26 Jan 2018, Szabolcs Nagy wrote:

> note that the FLAG_RISCV_FLOAT_ABI_SOFT ldconfig.h macro
> value conflicts with the arm/ilp32 branch, i can update this
> in the ilp32 branch but ldconfig will print existing ilp32
> ld.so.cache files incorrectly.

I don't think we expect ld.so.cache compatibility between different 
releases, and certainly not between releases and versions not on master.

Indeed, that was the basis on which I reviewed the patch - because at the 
time the patch series included RV32 support, so there were actually four 
ABIs involved, and so if the Linux kernel gained support for running RV32 
binaries on RV64 systems, four rather than two flag values would be needed 
and there would be incompatibility in those values for whichever of RV32 
and RV64 changed values.

(If RV32 support is added in future to glibc without the multi-ABI support 
for ldconfig / ldd / ld.so.cache for RV32 binaries on RV64 systems, I'd 
still consider it OK just to keep the two values.  It's only at the point 
where you add support for RV32 binaries on RV64 systems that it needs to 
become four values, and as per the above, I'm assuming it's OK to change 
the meaning of ld.so.cache values at that point.)
  

Patch

diff --git a/elf/cache.c b/elf/cache.c
index 1ec6ab36e7f7..c2c010f97bb2 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -114,6 +114,12 @@  print_entry (const char *lib, int flag, unsigned int osversion,
     case FLAG_MIPS64_LIBN64_NAN2008:
       fputs (",64bit,nan2008", stdout);
       break;
+    case FLAG_RISCV_FLOAT_ABI_SOFT:
+      fputs (",soft-float", stdout);
+      break;
+    case FLAG_RISCV_FLOAT_ABI_DOUBLE:
+      fputs (",double-float", stdout);
+      break;
     case 0:
       break;
     default:
diff --git a/elf/elf.h b/elf/elf.h
index 66af3dc0ea61..954f3266f711 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -3766,6 +3766,14 @@  enum
 
 #define R_TILEGX_NUM		130
 
+/* RISC-V ELF Flags */
+#define EF_RISCV_RVC 			0x0001
+#define EF_RISCV_FLOAT_ABI 		0x0006
+#define EF_RISCV_FLOAT_ABI_SOFT 	0x0000
+#define EF_RISCV_FLOAT_ABI_SINGLE 	0x0002
+#define EF_RISCV_FLOAT_ABI_DOUBLE 	0x0004
+#define EF_RISCV_FLOAT_ABI_QUAD 	0x0006
+
 /* RISC-V relocations.  */
 #define R_RISCV_NONE          0
 #define R_RISCV_32            1
diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h
index 74eb92e528d5..59e20dc3ef79 100644
--- a/sysdeps/generic/ldconfig.h
+++ b/sysdeps/generic/ldconfig.h
@@ -42,6 +42,8 @@ 
 #define FLAG_MIPS_LIB32_NAN2008		0x0c00
 #define FLAG_MIPS64_LIBN32_NAN2008	0x0d00
 #define FLAG_MIPS64_LIBN64_NAN2008	0x0e00
+#define FLAG_RISCV_FLOAT_ABI_SOFT	0x0f00
+#define FLAG_RISCV_FLOAT_ABI_DOUBLE	0x1000
 
 /* Name of auxiliary cache.  */
 #define _PATH_LDCONFIG_AUX_CACHE "/var/cache/ldconfig/aux-cache"