[PATCH v5 2/3] bfd: fill in PE load config directory entry.
Jan Beulich
jbeulich@suse.com
Thu Apr 3 08:50:09 GMT 2025
On 03.04.2025 00:53, Jeremy Drake wrote:
> @@ -4573,6 +4575,71 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
> #endif
> }
>
> + name[0] = bfd_get_symbol_leading_char (abfd);
> + strcpy (name + !!name[0], "_load_config_used");
> + h1 = coff_link_hash_lookup (coff_hash_table (info), name, false, false, true);
> + if (h1 != NULL)
> + {
> + char data[4];
> + if ((h1->root.type == bfd_link_hash_defined
> + || h1->root.type == bfd_link_hash_defweak)
> + && h1->root.u.def.section != NULL
> + && h1->root.u.def.section->output_section != NULL)
> + {
> + pe_data (abfd)->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE].VirtualAddress =
> + (h1->root.u.def.value
> + + h1->root.u.def.section->output_section->vma
> + + h1->root.u.def.section->output_offset
> + - pe_data (abfd)->pe_opthdr.ImageBase);
> +
> + if (pe_data (abfd)->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE].VirtualAddress &
> + ((bfd_arch_bits_per_address (abfd) >> 3) - 1))
Instead of shifting by 3, wouldn't you better divide by bfd_arch_bits_per_byte()?
Okay with this adjustment and the message text adjustments requested in reply to
patch 1.
Jan
More information about the Binutils
mailing list