This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [ELF] symbol sets handling


Hello,

Here's a patch to elf32.em, which slightly changes the way symbol sets are
handled. Basically, the patch serves to make the __start_<set> and
__stop_<set> symbols be relative to the <set> section, rather than being
absolute. This approach will make the -Ur option really useful, since
absolute symbols are meaningless for relocatable executables (used by
AROS, for instance), and it won't affect in any way the normal executables.


2003-01-30  Fabio Alemagna  <falemagn@aros.org>

        * emultempl/elf32.em(gld${EMULATION_NAME}_place_orphan):
	  Make the __start_<set> and __stop_<set> symbols be
	  relative to the <set> section, rather than being absolute.

Index: elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.89
diff -c -r1.89 elf32.em
*** elf32.em	17 Jan 2003 10:36:49 -0000	1.89
--- elf32.em	30 Jan 2003 16:39:27 -0000
***************
*** 1252,1277 ****
        lang_list_init (stat_ptr);
      }

-   if (config.build_constructors)
-     {
-       /* If the name of the section is representable in C, then create
- 	 symbols to mark the start and the end of the section.  */
-       for (ps = secname; *ps != '\0'; ps++)
- 	if (! ISALNUM (*ps) && *ps != '_')
- 	  break;
-       if (*ps == '\0')
- 	{
- 	  char *symname;
- 	  etree_type *e_align;
-
- 	  symname = (char *) xmalloc (ps - secname + sizeof "__start_");
- 	  sprintf (symname, "__start_%s", secname);
- 	  e_align = exp_unop (ALIGN_K,
- 			      exp_intop ((bfd_vma) 1 << s->alignment_power));
- 	  lang_add_assignment (exp_assop ('=', symname, e_align));
- 	}
-     }
-
    address = NULL;
    if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
      address = exp_intop ((bfd_vma) 0);
--- 1252,1257 ----
***************
*** 1293,1318 ****
  					    (etree_type *) NULL,
  					    load_base);

!   lang_add_section (&os->children, s, os, file);

!   lang_leave_output_section_statement
!     ((bfd_vma) 0, "*default*",
!      (struct lang_output_section_phdr_list *) NULL, NULL);

    if (config.build_constructors && *ps == '\0')
      {
        char *symname;

-       /* lang_leave_ouput_section_statement resets stat_ptr.  Put
- 	 stat_ptr back where we want it.  */
-       if (place != NULL)
- 	stat_ptr = &add;
-
        symname = (char *) xmalloc (ps - secname + sizeof "__stop_");
        sprintf (symname, "__stop_%s", secname);
        lang_add_assignment (exp_assop ('=', symname,
  				      exp_nameop (NAME, ".")));
      }

    /* Restore the global list pointer.  */
    stat_ptr = old;
--- 1273,1313 ----
  					    (etree_type *) NULL,
  					    load_base);

!   if (config.build_constructors)
!     {
!       /* If the name of the section is representable in C, then create
! 	 symbols to mark the start and the end of the section.  */
!       for (ps = secname; *ps != '\0'; ps++)
! 	if (! ISALNUM (*ps) && *ps != '_')
! 	  break;
!       if (*ps == '\0')
! 	{
! 	  char *symname;
! 	  etree_type *e_align;

! 	  symname = (char *) xmalloc (ps - secname + sizeof "__start_");
! 	  sprintf (symname, "__start_%s", secname);
! 	  e_align = exp_unop (ALIGN_K,
! 			      exp_intop ((bfd_vma) 1 << s->alignment_power));
! 	  lang_add_assignment (exp_assop ('=', symname, e_align));
! 	}
!     }
!
!   lang_add_section (&os->children, s, os, file);

    if (config.build_constructors && *ps == '\0')
      {
        char *symname;

        symname = (char *) xmalloc (ps - secname + sizeof "__stop_");
        sprintf (symname, "__stop_%s", secname);
        lang_add_assignment (exp_assop ('=', symname,
  				      exp_nameop (NAME, ".")));
      }
+
+   lang_leave_output_section_statement
+     ((bfd_vma) 0, "*default*",
+      (struct lang_output_section_phdr_list *) NULL, NULL);

    /* Restore the global list pointer.  */
    stat_ptr = old;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]