Home | History | Annotate | Download | only in gdb
      1 diff --git a/gdb-7.1.x/gdb/gdbserver/server.c b/gdb-7.1.x/gdb/gdbserver/server.c
      2 index a03f877..c4214f9 100644
      3 --- a/gdb-7.1.x/gdb/gdbserver/server.c
      4 +++ b/gdb-7.1.x/gdb/gdbserver/server.c
      5 @@ -76,12 +76,14 @@ pid_t old_foreground_pgrp;
      6  
      7  /* Hand back terminal ownership to the original foreground group.  */
      8  
      9 +#ifndef __ANDROID__
     10  static void
     11  restore_old_foreground_pgrp (void)
     12  {
     13    tcsetpgrp (terminal_fd, old_foreground_pgrp);
     14  }
     15  #endif
     16 +#endif
     17  
     18  /* Set if you want to disable optional thread related packets support
     19     in gdbserver, for the sake of testing GDB against stubs that don't
     20 @@ -257,11 +259,13 @@ start_inferior (char **argv)
     21  #ifdef SIGTTOU
     22    signal (SIGTTOU, SIG_IGN);
     23    signal (SIGTTIN, SIG_IGN);
     24 +#ifndef __ANDROID__
     25    terminal_fd = fileno (stderr);
     26    old_foreground_pgrp = tcgetpgrp (terminal_fd);
     27    tcsetpgrp (terminal_fd, signal_pid);
     28    atexit (restore_old_foreground_pgrp);
     29  #endif
     30 +#endif
     31  
     32    if (wrapper_argv != NULL)
     33      {
     34 diff --git a/gdb-7.3.x/gdb/gdbserver/config.in b/gdb-7.3.x/gdb/gdbserver/config.in
     35 index 4882d80..62d2fe1 100644
     36 --- a/gdb-7.3.x/gdb/gdbserver/config.in
     37 +++ b/gdb-7.3.x/gdb/gdbserver/config.in
     38 @@ -41,6 +41,12 @@
     39  /* Define to 1 if you have the `dladdr' function. */
     40  #undef HAVE_DLADDR
     41  
     42 +/* Define to 1 if the system has the type `Elf32_auxv_t'. */
     43 +#undef HAVE_ELF32_AUXV_T
     44 +
     45 +/* Define to 1 if the system has the type `Elf64_auxv_t'. */
     46 +#undef HAVE_ELF64_AUXV_T
     47 +
     48  /* Define if <sys/procfs.h> has elf_fpregset_t. */
     49  #undef HAVE_ELF_FPREGSET_T
     50  
     51 @@ -257,6 +257,9 @@
     52     when building for Cygwin. */
     53  #undef USE_WIN32API
     54  
     55 +/* Define to 1 if you have the <sys/un.h> header file. */
     56 +#undef HAVE_SYS_UN_H
     57 +
     58  /* Define if an XML target description is available. */
     59  #undef USE_XML
     60  
     61 diff --git a/gdb-7.3.x/gdb/gdbserver/configure b/gdb-7.3.x/gdb/gdbserver/configure
     62 index 110e406..0696030 100755
     63 --- a/gdb-7.3.x/gdb/gdbserver/configure
     64 +++ b/gdb-7.3.x/gdb/gdbserver/configure
     65 @@ -587,6 +587,9 @@ ac_includes_default="\
     66  #endif
     67  #ifdef HAVE_UNISTD_H
     68  # include <unistd.h>
     69 +#endif
     70 +#ifdef HAVE_SYS_SOCKET_H
     71 +# include <sys/socket.h>
     72  #endif"
     73  
     74  ac_subst_vars='LTLIBOBJS
     75 @@ -3994,7 +3997,7 @@ _ACEOF
     76  
     77  fi
     78  
     79 -for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h 		 proc_service.h sys/procfs.h thread_db.h linux/elf.h 		 stdlib.h unistd.h 		 errno.h fcntl.h signal.h sys/file.h malloc.h 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h 		 netinet/tcp.h arpa/inet.h sys/wait.h
     80 +for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h 		 proc_service.h sys/procfs.h thread_db.h linux/elf.h 		 stdlib.h unistd.h 		 errno.h fcntl.h signal.h sys/file.h malloc.h 		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h 		 netinet/tcp.h arpa/inet.h sys/wait.h sys/un.h
     81  do :
     82    as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
     83  ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
     84 @@ -4319,6 +4319,30 @@ _ACEOF
     85  fi
     86  
     87  
     88 +ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
     89 +
     90 +"
     91 +if test "x$ac_cv_type_Elf32_auxv_t" = x""yes; then :
     92 +
     93 +cat >>confdefs.h <<_ACEOF
     94 +#define HAVE_ELF32_AUXV_T 1
     95 +_ACEOF
     96 +
     97 +
     98 +fi
     99 +ac_fn_c_check_type "$LINENO" "Elf64_auxv_t" "ac_cv_type_Elf64_auxv_t" "#include <elf.h>
    100 +
    101 +"
    102 +if test "x$ac_cv_type_Elf64_auxv_t" = x""yes; then :
    103 +
    104 +cat >>confdefs.h <<_ACEOF
    105 +#define HAVE_ELF64_AUXV_T 1
    106 +_ACEOF
    107 +
    108 +
    109 +fi
    110 +
    111 +
    112  # Check whether --enable-googleisms was given.
    113  if test "${enable_googleisms+set}" = set; then :
    114    enableval=$enable_googleisms; case "${enableval}" in
    115 diff --git a/gdb-7.3.x/gdb/gdbserver/configure.ac b/gdb-7.3.x/gdb/gdbserver/configure.ac
    116 index c70f3cf..d78f267 100644
    117 --- a/gdb-7.3.x/gdb/gdbserver/configure.ac
    118 +++ b/gdb-7.3.x/gdb/gdbserver/configure.ac
    119 @@ -42,7 +42,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
    120  		 stdlib.h unistd.h dnl
    121  		 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
    122  		 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
    123 -		 netinet/tcp.h arpa/inet.h sys/wait.h)
    124 +		 netinet/tcp.h arpa/inet.h sys/wait.h sys/un.h)
    125  AC_CHECK_FUNCS(pread pwrite pread64)
    126  AC_REPLACE_FUNCS(memmem vasprintf vsnprintf)
    127  
    128 diff --git a/gdb-7.3.x/gdb/gdbserver/linux-low.c b/gdb-7.3.x/gdb/gdbserver/linux-low.c
    129 index e65ec96..f91129f 100644
    130 --- a/gdb-7.3.x/gdb/gdbserver/linux-low.c
    131 +++ b/gdb-7.3.x/gdb/gdbserver/linux-low.c
    132 @@ -110,6 +110,36 @@
    133  #endif
    134  #endif
    135  
    136 +#ifndef HAVE_ELF32_AUXV_T
    137 +/* Copied from glibc's elf.h.  */
    138 +typedef struct
    139 +{
    140 +  uint32_t a_type;		/* Entry type */
    141 +  union
    142 +    {
    143 +      uint32_t a_val;		/* Integer value */
    144 +      /* We use to have pointer elements added here.  We cannot do that,
    145 +	 though, since it does not work when using 32-bit definitions
    146 +	 on 64-bit platforms and vice versa.  */
    147 +    } a_un;
    148 +} Elf32_auxv_t;
    149 +#endif
    150 +
    151 +#ifndef HAVE_ELF64_AUXV_T
    152 +/* Copied from glibc's elf.h.  */
    153 +typedef struct
    154 +{
    155 +  uint64_t a_type;		/* Entry type */
    156 +  union
    157 +    {
    158 +      uint64_t a_val;		/* Integer value */
    159 +      /* We use to have pointer elements added here.  We cannot do that,
    160 +	 though, since it does not work when using 32-bit definitions
    161 +	 on 64-bit platforms and vice versa.  */
    162 +    } a_un;
    163 +} Elf64_auxv_t;
    164 +#endif
    165 +
    166  /* ``all_threads'' is keyed by the LWP ID, which we use as the GDB protocol
    167     representation of the thread ID.
    168  
    169 @@ -3816,7 +3846,7 @@ regsets_fetch_inferior_registers (struct regcache *regcache)
    170  	data = buf;
    171  
    172  #ifndef __sparc__
    173 -      res = ptrace (regset->get_request, pid, nt_type, data);
    174 +      res = ptrace (regset->get_request, pid, (PTRACE_ARG3_TYPE)nt_type, data);
    175  #else
    176        res = ptrace (regset->get_request, pid, data, nt_type);
    177  #endif
    178 @@ -3889,7 +3919,7 @@ regsets_store_inferior_registers (struct regcache *regcache)
    179  	data = buf;
    180  
    181  #ifndef __sparc__
    182 -      res = ptrace (regset->get_request, pid, nt_type, data);
    183 +      res = ptrace (regset->get_request, pid, (PTRACE_ARG3_TYPE)nt_type, data);
    184  #else
    185        res = ptrace (regset->get_request, pid, &iov, data);
    186  #endif
    187 @@ -3901,7 +3931,7 @@ regsets_store_inferior_registers (struct regcache *regcache)
    188  
    189  	  /* Only now do we write the register set.  */
    190  #ifndef __sparc__
    191 -	  res = ptrace (regset->set_request, pid, nt_type, data);
    192 +	  res = ptrace (regset->set_request, pid, (PTRACE_ARG3_TYPE)nt_type, data);
    193  #else
    194  	  res = ptrace (regset->set_request, pid, data, nt_type);
    195  #endif
    196 diff --git a/gdb-7.3.x/gdb/gdbserver/linux-x86-low.c b/gdb-7.3.x/gdb/gdbserver/linux-x86-low.c
    197 index 69c6b57..cdc0a18 100644
    198 --- a/gdb-7.3.x/gdb/gdbserver/linux-x86-low.c
    199 +++ b/gdb-7.3.x/gdb/gdbserver/linux-x86-low.c
    200 @@ -57,8 +57,13 @@ static const char *xmltarget_amd64_linux_no_xml = "@<target>\
    201  </target>";
    202  #endif
    203  
    204 +#ifdef HAVE_SYS_REG_H
    205  #include <sys/reg.h>
    206 +#endif
    207 +#ifdef HAVE_SYS_PROCFS_H
    208  #include <sys/procfs.h>
    209 +#endif
    210 +
    211  #include <sys/ptrace.h>
    212  #include <sys/uio.h>
    213  
    214 @@ -80,6 +85,9 @@ static const char *xmltarget_amd64_linux_no_xml = "@<target>\
    215  #define PTRACE_ARCH_PRCTL      30
    216  #endif
    217  
    218 +#define PTRACE_ARG3_TYPE       void*
    219 +#define PTRACE_ARG4_TYPE       void*
    220 +
    221  /* The following definitions come from prctl.h, but may be absent
    222     for certain configurations.  */
    223  #ifndef ARCH_GET_FS
    224 @@ -187,7 +195,7 @@ ps_get_thread_area (const struct ps_prochandle *ph,
    225      unsigned int desc[4];
    226  
    227      if (ptrace (PTRACE_GET_THREAD_AREA, lwpid,
    228 -		(void *) (intptr_t) idx, (unsigned long) &desc) < 0)
    229 +		(void *) (intptr_t) idx, (PTRACE_ARG4_TYPE) &desc) < 0)
    230        return PS_ERR;
    231  
    232      *(int *)base = desc[1];
    233 @@ -233,7 +241,7 @@ x86_get_thread_area (int lwpid, CORE_ADDR *addr)
    234  
    235      if (ptrace (PTRACE_GET_THREAD_AREA,
    236  		lwpid_of (lwp),
    237 -		(void *) (long) idx, (unsigned long) &desc) < 0)
    238 +		(void *) (long) idx, (PTRACE_ARG4_TYPE) &desc) < 0)
    239        return -1;
    240  
    241      *addr = desc[1];
    242 @@ -441,7 +449,7 @@ x86_linux_dr_get (ptid_t ptid, int regnum)
    243  
    244    errno = 0;
    245    value = ptrace (PTRACE_PEEKUSER, tid,
    246 -		  offsetof (struct user, u_debugreg[regnum]), 0);
    247 +		  (PTRACE_ARG3_TYPE)offsetof (struct user, u_debugreg[regnum]), 0);
    248    if (errno != 0)
    249      error ("Couldn't read debug register");
    250  
    251 @@ -457,7 +465,7 @@ x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
    252  
    253    errno = 0;
    254    ptrace (PTRACE_POKEUSER, tid,
    255 -	  offsetof (struct user, u_debugreg[regnum]), value);
    256 +	  (PTRACE_ARG3_TYPE)offsetof (struct user, u_debugreg[regnum]), (PTRACE_ARG4_TYPE)value);
    257    if (errno != 0)
    258      error ("Couldn't write debug register");
    259  }
    260 @@ -963,7 +971,7 @@ x86_linux_update_xmltarget (void)
    261  	{
    262  	  elf_fpxregset_t fpxregs;
    263  
    264 -	  if (ptrace (PTRACE_GETFPXREGS, pid, 0, (int) &fpxregs) < 0)
    265 +	  if (ptrace (PTRACE_GETFPXREGS, pid, 0, (PTRACE_ARG4_TYPE) &fpxregs) < 0)
    266  	    {
    267  	      have_ptrace_getfpxregs = 0;
    268  	      x86_xcr0 = I386_XSTATE_X87_MASK;
    269 @@ -1018,7 +1026,7 @@ x86_linux_update_xmltarget (void)
    270        iov.iov_len = sizeof (xstateregs);
    271  
    272        /* Check if PTRACE_GETREGSET works.  */
    273 -      if (ptrace (PTRACE_GETREGSET, pid, (unsigned int) NT_X86_XSTATE,
    274 +      if (ptrace (PTRACE_GETREGSET, pid, (PTRACE_ARG3_TYPE) NT_X86_XSTATE,
    275  		  &iov) < 0)
    276  	{
    277  	  have_ptrace_getregset = 0;
    278 diff --git a/gdb-7.3.x/gdb/gdbserver/remote-utils.c b/gdb-7.3.x/gdb/gdbserver/remote-utils.c
    279 index 02f13f4..3ce10f7 100644
    280 --- a/gdb-7.3.x/gdb/gdbserver/remote-utils.c
    281 +++ b/gdb-7.3.x/gdb/gdbserver/remote-utils.c
    282 @@ -61,10 +61,12 @@
    283  #if HAVE_ERRNO_H
    284  #include <errno.h>
    285  #endif
    286 -
    287  #if USE_WIN32API
    288  #include <winsock2.h>
    289  #endif
    290 +#if HAVE_SYS_UN_H
    291 +#include <sys/un.h>
    292 +#endif
    293  
    294  #if __QNX__
    295  #include <sys/iomgr.h>
    296 @@ -240,6 +242,45 @@ remote_open (char *name)
    297  {
    298    char *port_str;
    299  
    300 +#ifdef HAVE_SYS_UN_H
    301 +  if (name[0] == '+')
    302 +    {
    303 +#ifdef USE_WIN32API
    304 +      error ("Only <host>:<port> is supported on this platform.");
    305 +#else
    306 +      struct sockaddr_un sockaddr;
    307 +      socklen_t sockaddrlen;
    308 +
    309 +      name += 1; // skip the initial +
    310 +
    311 +      listen_desc = socket (AF_UNIX, SOCK_STREAM, 0);
    312 +      if (listen_desc < 0)
    313 +        perror_with_name ("Could not create Unix-domain socket");
    314 +
    315 +      memset (&sockaddr, 0, sizeof sockaddr);
    316 +      sockaddr.sun_family = AF_UNIX;
    317 +      strlcpy(sockaddr.sun_path, name, sizeof sockaddr.sun_path);
    318 +
    319 +      unlink (sockaddr.sun_path);
    320 +      sockaddrlen = sizeof(sockaddr.sun_family) + strlen(sockaddr.sun_path) + 1;
    321 +      if (bind (listen_desc, (struct sockaddr *)&sockaddr, sockaddrlen) < 0)
    322 +        perror_with_name ("Could not bind to Unix-domain socket");
    323 +      if (listen (listen_desc, 1) < 0)
    324 +        perror_with_name ("Could not listen to Unix-domain socket");
    325 +
    326 +      fprintf (stderr, "Listening on Unix socket %s\n", sockaddr.sun_path);
    327 +      fflush (stderr);
    328 +
    329 +      /* Register the event loop handler.  */
    330 +      add_file_handler (listen_desc, handle_accept_event, NULL);
    331 +
    332 +      transport_is_reliable = 1;
    333 +#endif
    334 +    }
    335 +  else
    336 +#endif /* HAVE_SYS_UN_H */
    337 +  {
    338 +
    339    port_str = strchr (name, ':');
    340  
    341    if (remote_connection_is_stdio (name))
    342 @@ -392,6 +433,7 @@ remote_open (char *name)
    343  
    344        transport_is_reliable = 1;
    345      }
    346 +  }
    347  }
    348  
    349  void
    350 diff --git a/gdb-7.3.x/gdb/gdbserver/server.c b/gdb-7.3.x/gdb/gdbserver/server.c
    351 index 5148dc8..9daceff 100644
    352 --- a/gdb-7.3.x/gdb/gdbserver/server.c
    353 +++ b/gdb-7.3.x/gdb/gdbserver/server.c
    354 @@ -75,12 +75,14 @@ pid_t old_foreground_pgrp;
    355  
    356  /* Hand back terminal ownership to the original foreground group.  */
    357  
    358 +#ifndef __ANDROID__
    359  static void
    360  restore_old_foreground_pgrp (void)
    361  {
    362 -  tcsetpgrp (terminal_fd, old_foreground_pgrp);
    363 +   tcsetpgrp (terminal_fd, old_foreground_pgrp);
    364  }
    365  #endif
    366 +#endif
    367  
    368  /* Set if you want to disable optional thread related packets support
    369     in gdbserver, for the sake of testing GDB against stubs that don't
    370 @@ -266,11 +268,13 @@ start_inferior (char **argv)
    371  #ifdef SIGTTOU
    372    signal (SIGTTOU, SIG_IGN);
    373    signal (SIGTTIN, SIG_IGN);
    374 +#ifndef __ANDROID__
    375    terminal_fd = fileno (stderr);
    376    old_foreground_pgrp = tcgetpgrp (terminal_fd);
    377    tcsetpgrp (terminal_fd, signal_pid);
    378    atexit (restore_old_foreground_pgrp);
    379  #endif
    380 +#endif
    381  
    382    if (wrapper_argv != NULL)
    383      {
    384 diff --git a/gdb-7.3.x/gdb/gdbserver/thread-db.c b/gdb-7.3.x/gdb/gdbserver/thread-db.c
    385 index 741c48b..3467b64 100644
    386 --- a/gdb-7.3.x/gdb/gdbserver/thread-db.c
    387 +++ b/gdb-7.3.x/gdb/gdbserver/thread-db.c
    388 @@ -565,7 +565,7 @@ thread_db_load_search (void)
    389    tdb->td_symbol_list_p = &td_symbol_list;
    390  
    391    /* This is required only when thread_db_use_events is on.  */
    392 -  tdb->td_thr_event_enable_p = &td_thr_event_enable;
    393 +  tdb->td_thr_event_enable_p = (void*)&td_thr_event_enable;
    394  
    395    /* These are not essential.  */
    396    tdb->td_ta_event_addr_p = &td_ta_event_addr;
    397 diff --git a/gdb-7.3.x/include/elf/common.h b/gdb-7.3.x/include/elf/common.h
    398 index 52ce9a5..a01e40c 100644
    399 --- a/gdb-7.3.x/include/elf/common.h
    400 +++ b/gdb-7.3.x/include/elf/common.h
    401 @@ -35,7 +35,9 @@
    402  /* Fields in e_ident[].  */
    403  
    404  #define EI_MAG0		0	/* File identification byte 0 index */
    405 +#ifndef ELFMAG0
    406  #define ELFMAG0		   0x7F	/* Magic number byte 0 */
    407 +#endif
    408  
    409  #define EI_MAG1		1	/* File identification byte 1 index */
    410  #define ELFMAG1		    'E'	/* Magic number byte 1 */
    411 @@ -82,7 +84,9 @@
    412  
    413  #define EI_ABIVERSION	8	/* ABI version */
    414  
    415 +#ifndef EI_PAD
    416  #define EI_PAD		9	/* Start of padding bytes */
    417 +#endif
    418  
    419  
    420  /* Values for e_type, which identifies the object file type.  */
    421 @@ -94,8 +98,12 @@
    422  #define ET_CORE		4	/* Core file */
    423  #define ET_LOOS		0xFE00	/* Operating system-specific */
    424  #define ET_HIOS		0xFEFF	/* Operating system-specific */
    425 +#ifndef ET_LOPROC
    426  #define ET_LOPROC	0xFF00	/* Processor-specific */
    427 +#endif
    428 +#ifndef ET_HIPROC
    429  #define ET_HIPROC	0xFFFF	/* Processor-specific */
    430 +#endif
    431  
    432  /* Values for e_machine, which identifies the architecture.  These numbers
    433     are officially assigned by registry (a] sco.com.  See below for a list of
    434 @@ -370,7 +378,9 @@
    435  #define EM_CYGNUS_V850		0x9080
    436  
    437  /* old S/390 backend magic number. Written in the absence of an ABI.  */
    438 +#ifndef EM_S390_OLD
    439  #define EM_S390_OLD		0xa390
    440 +#endif
    441  
    442  /* Old, unofficial value for Xtensa.  */
    443  #define EM_XTENSA_OLD		0xabc7
    444 @@ -423,18 +433,28 @@
    445  #define PT_LOOS		0x60000000	/* OS-specific */
    446  #define PT_HIOS		0x6fffffff	/* OS-specific */
    447  #define PT_LOPROC	0x70000000	/* Processor-specific */
    448 +#ifndef PT_HIPROC
    449  #define PT_HIPROC	0x7FFFFFFF	/* Processor-specific */
    450 +#endif
    451  
    452 +#ifndef PT_GNU_EH_FRAME
    453  #define PT_GNU_EH_FRAME	(PT_LOOS + 0x474e550) /* Frame unwind information */
    454 +#endif
    455  #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME      /* Solaris uses the same value */
    456  #define PT_GNU_STACK	(PT_LOOS + 0x474e551) /* Stack flags */
    457  #define PT_GNU_RELRO	(PT_LOOS + 0x474e552) /* Read-only after relocation */
    458  
    459  /* Program segment permissions, in program header p_flags field.  */
    460  
    461 +#ifndef PF_X
    462  #define PF_X		(1 << 0)	/* Segment is executable */
    463 +#endif
    464 +#ifndef PF_W
    465  #define PF_W		(1 << 1)	/* Segment is writable */
    466 +#endif
    467 +#ifndef PF_R
    468  #define PF_R		(1 << 2)	/* Segment is readable */
    469 +#endif
    470  /* #define PF_MASKOS	0x0F000000    *//* OS-specific reserved bits */
    471  #define PF_MASKOS	0x0FF00000	/* New value, Oct 4, 1999 Draft */
    472  #define PF_MASKPROC	0xF0000000	/* Processor-specific reserved bits */
    473 @@ -480,16 +500,26 @@
    474  #define SHT_GNU_versym	SHT_SUNW_versym
    475  
    476  #define SHT_LOPROC	0x70000000	/* Processor-specific semantics, lo */
    477 +#ifndef SHT_HIPROC
    478  #define SHT_HIPROC	0x7FFFFFFF	/* Processor-specific semantics, hi */
    479 +#endif
    480  #define SHT_LOUSER	0x80000000	/* Application-specific semantics */
    481  /* #define SHT_HIUSER	0x8FFFFFFF    *//* Application-specific semantics */
    482 +#ifndef SHT_HIUSER
    483  #define SHT_HIUSER	0xFFFFFFFF	/* New value, defined in Oct 4, 1999 Draft */
    484 +#endif
    485  
    486  /* Values for section header, sh_flags field.  */
    487  
    488 +#ifndef SHF_WRITE
    489  #define SHF_WRITE	(1 << 0)	/* Writable data during execution */
    490 +#endif
    491 +#ifndef SHF_ALLOC
    492  #define SHF_ALLOC	(1 << 1)	/* Occupies memory during execution */
    493 +#endif
    494 +#ifndef SHF_EXECINSTR
    495  #define SHF_EXECINSTR	(1 << 2)	/* Executable machine instructions */
    496 +#endif
    497  #define SHF_MERGE	(1 << 4)	/* Data in this section can be merged */
    498  #define SHF_STRINGS	(1 << 5)	/* Contains null terminated character strings */
    499  #define SHF_INFO_LINK	(1 << 6)	/* sh_info holds section header table index */
    500 @@ -500,7 +530,9 @@
    501  
    502  /* #define SHF_MASKOS	0x0F000000    *//* OS-specific semantics */
    503  #define SHF_MASKOS	0x0FF00000	/* New value, Oct 4, 1999 Draft */
    504 +#ifndef SHF_MASKPROC
    505  #define SHF_MASKPROC	0xF0000000	/* Processor-specific semantics */
    506 +#endif
    507  
    508  /* This used to be implemented as a processor specific section flag.
    509     We just make it generic.  */
    510 @@ -607,17 +639,29 @@
    511     which contains the symbol binding and symbol type.  The STB_ and STT_
    512     defines identify the binding and type.  */
    513  
    514 +#ifndef ELF_ST_BIND
    515  #define ELF_ST_BIND(val)		(((unsigned int)(val)) >> 4)
    516 +#endif
    517 +#ifndef ELF_ST_TYPE
    518  #define ELF_ST_TYPE(val)		((val) & 0xF)
    519 +#endif
    520  #define ELF_ST_INFO(bind,type)		(((bind) << 4) + ((type) & 0xF))
    521  
    522  /* The 64bit and 32bit versions of these macros are identical, but
    523     the ELF spec defines them, so here they are.  */
    524 +#ifndef ELF32_ST_BIND
    525  #define ELF32_ST_BIND  ELF_ST_BIND
    526 +#endif
    527 +#ifndef ELF32_ST_TYPE
    528  #define ELF32_ST_TYPE  ELF_ST_TYPE
    529 +#endif
    530  #define ELF32_ST_INFO  ELF_ST_INFO
    531 +#ifndef ELF64_ST_BIND
    532  #define ELF64_ST_BIND  ELF_ST_BIND
    533 +#endif
    534 +#ifndef ELF64_ST_TYPE
    535  #define ELF64_ST_TYPE  ELF_ST_TYPE
    536 +#endif
    537  #define ELF64_ST_INFO  ELF_ST_INFO
    538  
    539  /* This macro disassembles and assembles a symbol's visibility into
    540 @@ -667,8 +711,12 @@
    541  
    542  /* Relocation info handling macros.  */
    543  
    544 +#ifndef ELF32_R_SYM
    545  #define ELF32_R_SYM(i)		((i) >> 8)
    546 +#endif
    547 +#ifndef ELF32_R_TYPE
    548  #define ELF32_R_TYPE(i)		((i) & 0xff)
    549 +#endif
    550  #define ELF32_R_INFO(s,t)	(((s) << 8) + ((t) & 0xff))
    551  
    552  #define ELF64_R_SYM(i)		((i) >> 32)
    553