Home | History | Annotate | Line # | Download | only in bfd
      1   1.1  christos /* Matsushita AM33/2.0 support for 32-bit GNU/Linux ELF
      2  1.10  christos    Copyright (C) 2003-2025 Free Software Foundation, Inc.
      3   1.1  christos 
      4   1.1  christos    This file is part of BFD, the Binary File Descriptor library.
      5   1.1  christos 
      6   1.1  christos    This program is free software; you can redistribute it and/or modify
      7   1.1  christos    it under the terms of the GNU General Public License as published by
      8   1.1  christos    the Free Software Foundation; either version 3 of the License, or
      9   1.1  christos    (at your option) any later version.
     10   1.1  christos 
     11   1.1  christos    This program is distributed in the hope that it will be useful,
     12   1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   1.1  christos    GNU General Public License for more details.
     15   1.1  christos 
     16   1.1  christos    You should have received a copy of the GNU General Public License
     17   1.1  christos    along with this program; if not, write to the Free Software
     18   1.1  christos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     19   1.1  christos    MA 02110-1301, USA.  */
     20   1.1  christos 
     21   1.1  christos #include "sysdep.h"
     22   1.1  christos #include "bfd.h"
     23   1.1  christos #include "elf-bfd.h"
     24   1.1  christos #include "elf/mn10300.h"
     25   1.1  christos 
     26   1.1  christos #define elf_symbol_leading_char 0
     27   1.1  christos 
     28   1.3  christos #define TARGET_LITTLE_SYM	am33_elf32_linux_vec
     29   1.1  christos #define TARGET_LITTLE_NAME	"elf32-am33lin"
     30   1.1  christos #define ELF_ARCH		bfd_arch_mn10300
     31  1.10  christos #define ELF_TARGET_ID		MN10300_ELF_DATA
     32   1.1  christos #define ELF_MACHINE_CODE	EM_MN10300
     33   1.1  christos #define ELF_MACHINE_ALT1	EM_CYGNUS_MN10300
     34   1.1  christos #define ELF_MAXPAGESIZE		0x1000
     35   1.1  christos 
     36   1.1  christos /* Rename global functions.  */
     37   1.6  christos #define _bfd_mn10300_elf_merge_private_bfd_data	 _bfd_am33_elf_merge_private_bfd_data
     38   1.6  christos #define _bfd_mn10300_elf_object_p		 _bfd_am33_elf_object_p
     39   1.6  christos #define _bfd_mn10300_elf_final_write_processing	 _bfd_am33_elf_final_write_processing
     40   1.1  christos 
     41   1.1  christos /* Support for core dump NOTE sections.  */
     42   1.8  christos static bool
     43   1.1  christos elf32_am33lin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
     44   1.1  christos {
     45   1.1  christos   int offset;
     46   1.1  christos   unsigned int size;
     47   1.1  christos 
     48   1.1  christos   switch (note->descsz)
     49   1.1  christos     {
     50   1.1  christos       default:
     51   1.8  christos 	return false;
     52   1.1  christos 
     53   1.1  christos       case 184:
     54   1.1  christos       case 188:		/* Linux/am33 */
     55   1.1  christos 	/* pr_cursig */
     56   1.3  christos 	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
     57   1.1  christos 
     58   1.1  christos 	/* pr_pid */
     59   1.3  christos 	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
     60   1.1  christos 
     61   1.1  christos 	/* pr_reg */
     62   1.1  christos 	offset = 72;
     63   1.1  christos 	size = 112;
     64   1.1  christos 
     65   1.1  christos 	break;
     66   1.1  christos     }
     67   1.1  christos 
     68   1.1  christos   /* Make a ".reg/999" section.  */
     69   1.1  christos   return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
     70   1.1  christos 					  note->descpos + offset);
     71   1.1  christos }
     72   1.1  christos 
     73   1.8  christos static bool
     74   1.1  christos elf32_am33lin_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
     75   1.1  christos {
     76   1.1  christos   switch (note->descsz)
     77   1.1  christos     {
     78   1.1  christos       default:
     79   1.8  christos 	return false;
     80   1.1  christos 
     81   1.1  christos       case 124:		/* Linux/am33 elf_prpsinfo */
     82   1.3  christos 	elf_tdata (abfd)->core->program
     83   1.1  christos 	 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
     84   1.3  christos 	elf_tdata (abfd)->core->command
     85   1.1  christos 	 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     86   1.1  christos     }
     87   1.1  christos 
     88   1.1  christos   /* Note that for some reason, a spurious space is tacked
     89   1.1  christos      onto the end of the args in some (at least one anyway)
     90   1.1  christos      implementations, so strip it off if it exists.  */
     91   1.1  christos 
     92   1.1  christos   {
     93   1.3  christos     char *command = elf_tdata (abfd)->core->command;
     94   1.1  christos     int n = strlen (command);
     95   1.1  christos 
     96   1.1  christos     if (0 < n && command[n - 1] == ' ')
     97   1.1  christos       command[n - 1] = '\0';
     98   1.1  christos   }
     99   1.1  christos 
    100   1.8  christos   return true;
    101   1.1  christos }
    102   1.1  christos 
    103   1.1  christos #define elf_backend_grok_prstatus	elf32_am33lin_grok_prstatus
    104   1.1  christos #define elf_backend_grok_psinfo		elf32_am33lin_grok_psinfo
    105   1.1  christos 
    106   1.8  christos #define elf_backend_linux_prpsinfo32_ugid16	true
    107   1.6  christos 
    108   1.1  christos #include "elf-m10300.c"
    109