Re: [RFC] libdl: Make Elf_Sym::st_other available

2024-03-03 Thread Chris Johns
On 1/3/2024 6:05 pm, Sebastian Huber wrote:
> On 29.02.24 00:27, Chris Johns wrote:
>> On 27/2/2024 6:46 pm, Sebastian Huber wrote:
>>> The 64-bit PowerPC ELFv2 relocation support needs access to the
>>> Elf_Sym::st_other symbol information.  The machine-specific relocation 
>>> handler
>>> had only access to the Elf_Sym::st_info symbol information.  This change
>>> extends the 8-bit syminfo parameter to 16-bit and uses the additional
>>> 8-bits to provide Elf_Sym::st_other.  Another approach could be to pass
>>> a pointer to an Elf_Sym object instead of symname, syminfo, and
>>> symvalue.
>>
>> I think symname and symvalue have to stay or the code needed to support them
>> moves out to all reloc handlers [1]. I agree there is a limit to the number 
>> args
>> to keep adding. If there is a need for more fields then it may pay to pass in
>> Elf_Sym* or rtems_rtl_obj_sym* which is the symbol table reference?
>>
>> Chris
>>
>> [1] https://git.rtems.org/rtems/tree/cpukit/libdl/rtl-elf.c#n429
> 
> What do you prefer, a new st_other parameter, use Elf_Sym*, or use
> rtems_rtl_obj_sym*?
> 
> The
> 
> /**
>  * An object file symbol.
>  */
> typedef struct rtems_rtl_obj_sym
> {
>   rtems_chain_node node;    /**< The node's link in the chain. */
>   const char*  name;    /**< The symbol's name. */
>   void*    value;   /**< The value of the symbol. */
>   uint32_t data;    /**< Format specific data. */
> } rtems_rtl_obj_sym;
> 
> has no st_info and st_other members. I tend to pass a Elf_Sym* pointer.

Ah thanks. I think Elf_Sym* as changes to sizeof(rtems_rtl_obj_sym) effects the
size of the runtime symbol table. The data you need is only for resolving that
obj's relocs and nothing more if I understand things correctly.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [RFC] libdl: Make Elf_Sym::st_other available

2024-02-29 Thread Sebastian Huber

On 29.02.24 00:27, Chris Johns wrote:

On 27/2/2024 6:46 pm, Sebastian Huber wrote:

The 64-bit PowerPC ELFv2 relocation support needs access to the
Elf_Sym::st_other symbol information.  The machine-specific relocation handler
had only access to the Elf_Sym::st_info symbol information.  This change
extends the 8-bit syminfo parameter to 16-bit and uses the additional
8-bits to provide Elf_Sym::st_other.  Another approach could be to pass
a pointer to an Elf_Sym object instead of symname, syminfo, and
symvalue.


I think symname and symvalue have to stay or the code needed to support them
moves out to all reloc handlers [1]. I agree there is a limit to the number args
to keep adding. If there is a need for more fields then it may pay to pass in
Elf_Sym* or rtems_rtl_obj_sym* which is the symbol table reference?

Chris

[1] https://git.rtems.org/rtems/tree/cpukit/libdl/rtl-elf.c#n429


What do you prefer, a new st_other parameter, use Elf_Sym*, or use 
rtems_rtl_obj_sym*?


The

/**
 * An object file symbol.
 */
typedef struct rtems_rtl_obj_sym
{
  rtems_chain_node node;/**< The node's link in the chain. */
  const char*  name;/**< The symbol's name. */
  void*value;   /**< The value of the symbol. */
  uint32_t data;/**< Format specific data. */
} rtems_rtl_obj_sym;

has no st_info and st_other members. I tend to pass a Elf_Sym* pointer.

--
embedded brains GmbH & Co. KG
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [RFC] libdl: Make Elf_Sym::st_other available

2024-02-28 Thread Chris Johns
On 27/2/2024 6:46 pm, Sebastian Huber wrote:
> The 64-bit PowerPC ELFv2 relocation support needs access to the
> Elf_Sym::st_other symbol information.  The machine-specific relocation handler
> had only access to the Elf_Sym::st_info symbol information.  This change
> extends the 8-bit syminfo parameter to 16-bit and uses the additional
> 8-bits to provide Elf_Sym::st_other.  Another approach could be to pass
> a pointer to an Elf_Sym object instead of symname, syminfo, and
> symvalue.

I think symname and symvalue have to stay or the code needed to support them
moves out to all reloc handlers [1]. I agree there is a limit to the number args
to keep adding. If there is a need for more fields then it may pay to pass in
Elf_Sym* or rtems_rtl_obj_sym* which is the symbol table reference?

Chris

[1] https://git.rtems.org/rtems/tree/cpukit/libdl/rtl-elf.c#n429
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[RFC] libdl: Make Elf_Sym::st_other available

2024-02-26 Thread Sebastian Huber
The 64-bit PowerPC ELFv2 relocation support needs access to the
Elf_Sym::st_other symbol information.  The machine-specific relocation handler
had only access to the Elf_Sym::st_info symbol information.  This change
extends the 8-bit syminfo parameter to 16-bit and uses the additional
8-bits to provide Elf_Sym::st_other.  Another approach could be to pass
a pointer to an Elf_Sym object instead of symname, syminfo, and
symvalue.

Update #4996.
---
 cpukit/libdl/rtl-elf.c | 12 ++--
 cpukit/libdl/rtl-elf.h |  8 
 cpukit/libdl/rtl-mdreloc-powerpc.c | 10 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/cpukit/libdl/rtl-elf.c b/cpukit/libdl/rtl-elf.c
index dddf9aceab..cf56929198 100644
--- a/cpukit/libdl/rtl-elf.c
+++ b/cpukit/libdl/rtl-elf.c
@@ -275,7 +275,7 @@ rtems_rtl_elf_reloc_parser (rtems_rtl_obj*  obj,
   (uintmax_t) symvalue, (int) ELF_R_TYPE (rela->r_info),
   (uintmax_t) rela->r_offset, (int) rela->r_addend);
 rs = rtems_rtl_elf_relocate_rela_tramp (obj, rela, targetsect,
-symname, sym->st_info, symvalue);
+symname, (sym->st_other << 8) | 
sym->st_info, symvalue);
 rel_words[REL_R_OFFSET] = rela->r_offset;
 rel_words[REL_R_INFO] = rela->r_info;
 rel_words[REL_R_ADDEND] = rela->r_addend;
@@ -392,7 +392,7 @@ rtems_rtl_elf_reloc_relocator (rtems_rtl_obj*  obj,
 (uintmax_t) symvalue, (int) ELF_R_TYPE (rela->r_info),
 (uintmax_t) rela->r_offset, (int) rela->r_addend);
   rs = rtems_rtl_elf_relocate_rela (obj, rela, targetsect,
-symname, sym->st_info, symvalue);
+symname, (sym->st_other << 8) | 
sym->st_info, symvalue);
   if (rs != rtems_rtl_elf_rel_no_error)
 return false;
 }
@@ -404,7 +404,7 @@ rtems_rtl_elf_reloc_relocator (rtems_rtl_obj*  obj,
 (uintmax_t) symvalue, (int) ELF_R_TYPE (rel->r_info),
 (uintmax_t) rel->r_offset);
   rs = rtems_rtl_elf_relocate_rel (obj, rel, targetsect,
-   symname, sym->st_info, symvalue);
+   symname, (sym->st_other << 8) | 
sym->st_info, symvalue);
   if (rs != rtems_rtl_elf_rel_no_error)
 return false;
 }
@@ -1217,7 +1217,7 @@ rtems_rtl_elf_symbols_load (rtems_rtl_obj*  obj,
 memcpy (string, name, strlen (name) + 1);
 osym->name = string;
 osym->value = (void*) (intptr_t) value;
-osym->data = symbol.st_shndx;
+osym->data = (symbol.st_other << 8) | symbol.st_shndx;
 
 if (rtems_rtl_trace (RTEMS_RTL_TRACE_SYMBOL))
   printf ("rtl: sym:add:%-4d name:%-4d: %-20s: bind:%-2d " \
@@ -1246,7 +1246,7 @@ rtems_rtl_elf_symbols_locate (rtems_rtl_obj*  obj,
   {
   rtems_rtl_obj_sym*  osym = >local_table[sym];
   rtems_rtl_obj_sect* symsect;
-  symsect = rtems_rtl_obj_find_section_by_index (obj, osym->data);
+  symsect = rtems_rtl_obj_find_section_by_index (obj, osym->data & 0xff);
   if (symsect)
   {
 osym->value += (intptr_t) symsect->base;
@@ -1261,7 +1261,7 @@ rtems_rtl_elf_symbols_locate (rtems_rtl_obj*  obj,
   {
   rtems_rtl_obj_sym*  osym = >global_table[sym];
   rtems_rtl_obj_sect* symsect;
-  symsect = rtems_rtl_obj_find_section_by_index (obj, osym->data);
+  symsect = rtems_rtl_obj_find_section_by_index (obj, osym->data & 0xff);
   if (symsect)
   {
 osym->value += (intptr_t) symsect->base;
diff --git a/cpukit/libdl/rtl-elf.h b/cpukit/libdl/rtl-elf.h
index 0476c1ecd7..98b460e6f4 100644
--- a/cpukit/libdl/rtl-elf.h
+++ b/cpukit/libdl/rtl-elf.h
@@ -185,7 +185,7 @@ rtems_rtl_elf_rel_status rtems_rtl_elf_relocate_rel_tramp 
(rtems_rtl_obj*
const Elf_Rel*  
  rel,
const 
rtems_rtl_obj_sect* sect,
const char* 
  symname,
-   const Elf_Byte  
  syminfo,
+   const Elf_Half  
  syminfo,
const Elf_Word  
  symvalue);
 
 /**
@@ -205,7 +205,7 @@ rtems_rtl_elf_rel_status  rtems_rtl_elf_relocate_rela_tramp 
(rtems_rtl_obj*
  const Elf_Rela*   
rela,
  const 
rtems_rtl_obj_sect* sect,
  const char*   
symname,
- const Elf_Byte
syminfo,
+