[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/4844] auto-import and const data import problem

From: ebotcazou at gcc dot gnu dot org
Subject: [Bug ld/4844] auto-import and const data import problem
Date: 1 Oct 2007 13:47:57 -0000

------- Additional Comments From ebotcazou at gcc dot gnu dot org  2007-10-01 
13:47 -------
Hi Nick,

>   * The new script is only used when --enable-auto-import is present on the
> linker command line, not when the linker magically enables auto import for
> itself.  (There appears to be code in pe{p}.em:...find_data_imports() that
> magically enables auto importing.  I was not sure what should be done in this
> situation).

This is IMO a significant weakness as the auto-import feature is enabled
unless specifically disabled by --disable-auto-import.

I think that the definitive fix would be to make .rdata writable in this
case, much like the text section is made writable:

pe_create_import_fixup (arelent *rel, asection *s, int addend)
  char buf[300];
  struct bfd_symbol *sym = *rel->sym_ptr_ptr;
  struct bfd_link_hash_entry *name_thunk_sym;
  const char *name = sym->name;
  char *fixup_name = make_import_fixup_mark (rel);
  bfd *b;

  sprintf (buf, U ("_nm_thnk_%s"), name);

  name_thunk_sym = bfd_link_hash_lookup (link_info.hash, buf, 0, 0, 1);

  if (!name_thunk_sym || name_thunk_sym->type != bfd_link_hash_defined)
      bfd *b = make_singleton_name_thunk (name, output_bfd);
      add_bfd_to_link (b, b->filename, &link_info);

      /* If we ever use autoimport, we have to cast text section writable.  */
      config.text_read_only = FALSE;
      output_bfd->flags &= ~WP_TEXT;   

Of course only the section to which the relocation will be applied should be
made writable.



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]