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]

vxWorks-style symbol table extraction.


Hello,

The patch below add support to binutils to generate vxWorks-style symbol
table files.  Can this be incorporated into binutils?

Sean

2003-02-20  Sean McNeil  <sean at blue dot mcneil dot com>

	* objcopy.c:  Add support for vxWorks-style symbol table extraction.

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.44
diff -c -3 -p -r1.44 objcopy.c
*** binutils/objcopy.c  13 Dec 2002 13:19:44 -0000      1.44
--- binutils/objcopy.c  21 Feb 2003 00:52:16 -0000
*************** static bfd_boolean sections_removed;
*** 178,183 ****
--- 178,186 ----
  /* TRUE if only some sections are to be copied.  */
  static bfd_boolean sections_copied;
   
+ /* Flag for extract symbol option */
+ static bfd_boolean extract_symbol = FALSE;
+
  /* Changes to the start address.  */
  static bfd_vma change_start = 0;
  static bfd_boolean set_start_set = FALSE;
*************** static char *prefix_alloc_sections_strin
*** 275,280 ****
--- 278,284 ----
  #define OPTION_PREFIX_SYMBOLS (OPTION_ALT_MACH_CODE + 1)
  #define OPTION_PREFIX_SECTIONS (OPTION_PREFIX_SYMBOLS + 1)
  #define OPTION_PREFIX_ALLOC_SECTIONS (OPTION_PREFIX_SECTIONS + 1)
+ #define OPTION_EXTRACT_SYMBOL (OPTION_PREFIX_ALLOC_SECTIONS + 1)
   
  /* Options to handle if running as "strip".  */
   
*************** static struct option copy_options[] =
*** 324,329 ****
--- 328,334 ----
    {"debugging", no_argument, 0, OPTION_DEBUGGING},
    {"discard-all", no_argument, 0, 'x'},
    {"discard-locals", no_argument, 0, 'X'},
+   {"extract-symbol", no_argument, 0, OPTION_EXTRACT_SYMBOL},
    {"format", required_argument, 0, 'F'}, /* Obsolete */
    {"gap-fill", required_argument, 0, OPTION_GAP_FILL},
    {"help", no_argument, 0, 'h'},
*************** copy_object (ibfd, obfd)
*** 1015,1020 ****
--- 1020,1027 ----
   
    if (set_start_set)
      start = set_start;
+   else if (extract_symbol)
+     start = 0;
    else
      start = bfd_get_start_address (ibfd);
    start += change_start;
*************** copy_object (ibfd, obfd)
*** 1311,1317 ****
       from the input BFD to the output BFD.  This is done last to
       permit the routine to look at the filtered symbol table, which is
       important for the ECOFF code at least.  */
!   if (! bfd_copy_private_bfd_data (ibfd, obfd))
      {
        non_fatal (_("%s: error copying private BFD data: %s"),
                 bfd_get_filename (obfd),
--- 1318,1324 ----
       from the input BFD to the output BFD.  This is done last to
       permit the routine to look at the filtered symbol table, which is
       important for the ECOFF code at least.  */
!   if (! (extract_symbol || bfd_copy_private_bfd_data (ibfd, obfd)))
      {
        non_fatal (_("%s: error copying private BFD data: %s"),
                 bfd_get_filename (obfd),
*************** setup_section (ibfd, isection, obfdarg)
*** 1747,1758 ****
    isection->output_section = osection;
    isection->output_offset = 0;
   
!   /* Allow the BFD backend to copy any private data it understands
!      from the input section to the output section.  */
!   if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
      {
!       err = _("private data");
!       goto loser;
      }
   
    /* All went well.  */
--- 1754,1784 ----
    isection->output_section = osection;
    isection->output_offset = 0;
   
!   /* Object module has a 0 size in the case of extract_symbol */
!   /* otherwise, this is the size of the input object module.  */
!   if (extract_symbol)
      {
!       if (!bfd_set_section_size (obfd, osection, 0))
!         {
!           err = _("size");
!           goto loser;
!         }
!       if (! bfd_set_section_vma (obfd, osection, 0))
!       {
!         err = _("vma");
!         goto loser;
!       }
!       isection->output_offset = vma;
!     }
!   else
!     {
!       /* Allow the BFD backend to copy any private data it understands
!        from the input section to the output section.  */
!       if (!bfd_copy_private_section_data (ibfd, isection, obfd,
osection))
!       {
!         err = _("private data");
!         goto loser;
!       }
      }
   
    /* All went well.  */
*************** copy_section (ibfd, isection, obfdarg)
*** 1815,1820 ****
--- 1841,1849 ----
    if (size == 0 || osection == 0)
      return;
   
+   if (extract_symbol)
+     return;
+
    /* Core files do not need to be relocated.  */
    if (bfd_get_format (obfd) == bfd_core)
      relsize = 0;
*************** copy_main (argc, argv)
*** 2641,2646 ****
--- 2670,2685 ----
        case OPTION_PREFIX_ALLOC_SECTIONS:
          prefix_alloc_sections_string = optarg;
          break;
+
+         case OPTION_EXTRACT_SYMBOL:
+           /* Extract the symbol table from a object module.      */
+           /* The output module contains only the symbol table,   */
+           /* with no code, but is otherwise a normal, executable */
+           /* object module.                                      */
+           /* This tool is used to generate the VxWorks symbol    */
+           /* table, `vxWorks.sym'.                               */
+           extract_symbol = TRUE;
+           break;
   
        case 0:
          break;                /* we've been given a long option */



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