* Misleading names @ 2023-09-03 21:59 jacob navia 2023-09-04 0:04 ` Alan Modra 0 siblings, 1 reply; 4+ messages in thread From: jacob navia @ 2023-09-03 21:59 UTC (permalink / raw) To: binutils Hi The function riscv_elf_ignore_reloc, contrary to its name, does NOT ignore the relocation! /* Special handler for relocations which don't have to be relocated. This * function just simply return bfd_reloc_ok. */ static bfd_reloc_status_type riscv_elf_ignore_reloc(bfd * abfd ATTRIBUTE_UNUSED, arelent * reloc_entry, asymbol * symbol ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED, asection * input_section, bfd * output_bfd, char **error_message ATTRIBUTE_UNUSED) { if (output_bfd != NULL) reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; } Despite its name, and the associated comment, nothing is ignored here and the relocation address is modified. Long, descriptive names are very good WHEN THEY REFLECT THE TRUTH! Otherwise they are completely misleading. Of course this is not a bug. FILE: elfe-riscv.c LINE: 1053 Jacob ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Misleading names 2023-09-03 21:59 Misleading names jacob navia @ 2023-09-04 0:04 ` Alan Modra 2023-09-04 6:29 ` jacob navia 0 siblings, 1 reply; 4+ messages in thread From: Alan Modra @ 2023-09-04 0:04 UTC (permalink / raw) To: jacob navia; +Cc: binutils On Sun, Sep 03, 2023 at 11:59:28PM +0200, jacob navia wrote: > Hi > The function riscv_elf_ignore_reloc, contrary to its name, does NOT ignore the relocation! > > /* Special handler for relocations which don't have to be relocated. This > * function just simply return bfd_reloc_ok. */ > static bfd_reloc_status_type riscv_elf_ignore_reloc(bfd * abfd ATTRIBUTE_UNUSED, > arelent * reloc_entry, > asymbol * symbol ATTRIBUTE_UNUSED, > void *data ATTRIBUTE_UNUSED, > asection * input_section, > bfd * output_bfd, > char **error_message ATTRIBUTE_UNUSED) > { > if (output_bfd != NULL) > reloc_entry->address += input_section->output_offset; > return bfd_reloc_ok; > } > > Despite its name, and the associated comment, nothing is ignored here and the relocation address is modified. > > Long, descriptive names are very good WHEN THEY REFLECT THE TRUTH! > Otherwise they are completely misleading. > > Of course this is not a bug. There is nothing wrong with the name. No relocation of section contents is done. The only change made here is for ld -r to keep the relocation associated with the same location in the output as it was in the input. That said, I think it would be better for the R_RISCV_SET_ULEB128 and R_RISCV_SUB_ULEB128 howto to use a special function something like ppc64_elf_unhandled_reloc. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Misleading names 2023-09-04 0:04 ` Alan Modra @ 2023-09-04 6:29 ` jacob navia 2023-09-04 23:54 ` Alan Modra 0 siblings, 1 reply; 4+ messages in thread From: jacob navia @ 2023-09-04 6:29 UTC (permalink / raw) To: Alan Modra; +Cc: binutils [-- Attachment #1: Type: text/plain, Size: 2690 bytes --] Hi Alain In the context of an assembler, not a linker, input and output bed are the same: std output. The only call done to this special function is in bfd_install_relocation: cont = howto->special_function(abfd,reloc_entry,symbol, /* XXX - Non-portable! */ ((bfd_byte *) data_start - data_start_offset), input_section,abfd,error_message); Stdoutput is passed to both bfd pointers expected. As far as I see, this is a modification of the relocation, but I could be wrong. Note that stdoutput can NEVER be NULL, so the test doesn’t do anything here . What is surely difficult is that this functions are used in the linker context and in the assembler context, what makes making any modification very difficult. It could be better to separate a bit those 2 different functionalities, but I do not know the linker enough to be sure. Thanks for your input. Jacob > Le 4 sept. 2023 à 02:04, Alan Modra <amodra@gmail.com> a écrit : > > On Sun, Sep 03, 2023 at 11:59:28PM +0200, jacob navia wrote: >> Hi >> The function riscv_elf_ignore_reloc, contrary to its name, does NOT ignore the relocation! >> >> /* Special handler for relocations which don't have to be relocated. This >> * function just simply return bfd_reloc_ok. */ >> static bfd_reloc_status_type riscv_elf_ignore_reloc(bfd * abfd ATTRIBUTE_UNUSED, >> arelent * reloc_entry, >> asymbol * symbol ATTRIBUTE_UNUSED, >> void *data ATTRIBUTE_UNUSED, >> asection * input_section, >> bfd * output_bfd, >> char **error_message ATTRIBUTE_UNUSED) >> { >> if (output_bfd != NULL) >> reloc_entry->address += input_section->output_offset; >> return bfd_reloc_ok; >> } >> >> Despite its name, and the associated comment, nothing is ignored here and the relocation address is modified. >> >> Long, descriptive names are very good WHEN THEY REFLECT THE TRUTH! >> Otherwise they are completely misleading. >> >> Of course this is not a bug. > > There is nothing wrong with the name. No relocation of section > contents is done. The only change made here is for ld -r to keep the > relocation associated with the same location in the output as it was > in the input. > > That said, I think it would be better for the R_RISCV_SET_ULEB128 > and R_RISCV_SUB_ULEB128 howto to use a special function something like > ppc64_elf_unhandled_reloc. > > -- > Alan Modra > Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Misleading names 2023-09-04 6:29 ` jacob navia @ 2023-09-04 23:54 ` Alan Modra 0 siblings, 0 replies; 4+ messages in thread From: Alan Modra @ 2023-09-04 23:54 UTC (permalink / raw) To: jacob navia; +Cc: binutils On Mon, Sep 04, 2023 at 08:29:02AM +0200, jacob navia wrote: > Hi Alain > In the context of an assembler, not a linker, input and output bed are the same: std output. > > The only call done to this special function is in bfd_install_relocation: > > cont = howto->special_function(abfd,reloc_entry,symbol, > /* XXX - Non-portable! */ > ((bfd_byte *) data_start > - data_start_offset), > input_section,abfd,error_message); > > Stdoutput is passed to both bfd pointers expected. > > As far as I see, this is a modification of the relocation, but I could be wrong. It isn't, because input_section->output_offset is always zero for gas. > Note that stdoutput can NEVER be NULL, so the test doesn’t do anything here . > > What is surely difficult is that this functions are used in the linker context and in the assembler context, what makes making any modification very difficult. It could be better to separate a bit those 2 different functionalities, but I do not know the linker enough to be sure. Yes, there is a lot wrong with bfd_install_relocation, but don't underestimate the difficulty of cleaning things up. There are lots of hacks, eg. see md_apply_fix comments, to work around odd things in bfd_install_relocation. It you change anything there, you need to ensure *all* currently supported targets still produce working object files. > > Thanks for your input. > > Jacob > > > Le 4 sept. 2023 à 02:04, Alan Modra <amodra@gmail.com> a écrit : > > > > On Sun, Sep 03, 2023 at 11:59:28PM +0200, jacob navia wrote: > >> Hi > >> The function riscv_elf_ignore_reloc, contrary to its name, does NOT ignore the relocation! > >> > >> /* Special handler for relocations which don't have to be relocated. This > >> * function just simply return bfd_reloc_ok. */ > >> static bfd_reloc_status_type riscv_elf_ignore_reloc(bfd * abfd ATTRIBUTE_UNUSED, > >> arelent * reloc_entry, > >> asymbol * symbol ATTRIBUTE_UNUSED, > >> void *data ATTRIBUTE_UNUSED, > >> asection * input_section, > >> bfd * output_bfd, > >> char **error_message ATTRIBUTE_UNUSED) > >> { > >> if (output_bfd != NULL) > >> reloc_entry->address += input_section->output_offset; > >> return bfd_reloc_ok; > >> } > >> > >> Despite its name, and the associated comment, nothing is ignored here and the relocation address is modified. > >> > >> Long, descriptive names are very good WHEN THEY REFLECT THE TRUTH! > >> Otherwise they are completely misleading. > >> > >> Of course this is not a bug. > > > > There is nothing wrong with the name. No relocation of section > > contents is done. The only change made here is for ld -r to keep the > > relocation associated with the same location in the output as it was > > in the input. > > > > That said, I think it would be better for the R_RISCV_SET_ULEB128 > > and R_RISCV_SUB_ULEB128 howto to use a special function something like > > ppc64_elf_unhandled_reloc. > > > > -- > > Alan Modra > > Australia Development Lab, IBM > -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-04 23:54 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-09-03 21:59 Misleading names jacob navia 2023-09-04 0:04 ` Alan Modra 2023-09-04 6:29 ` jacob navia 2023-09-04 23:54 ` Alan Modra
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).