Print this page
remove support for non-ANSI compilation


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*

  22  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 
  25 #ifndef _LINK_H
  26 #define _LINK_H
  27 
  28 #include <sys/link.h>
  29 
  30 #ifndef _ASM
  31 #include <elf.h>
  32 #include <sys/types.h>
  33 #include <dlfcn.h>
  34 #endif
  35 
  36 #ifdef  __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 #ifndef _ASM
  41 /*
  42  * ld support library calls.
  43  *
  44  * These cannot be used in a 32bit large file capable environment because
  45  * libelf is not large-file safe.  Only define these interfaces if we are not
  46  * 32bit, or not in the large file environment.
  47  */
  48 #if !defined(_ILP32) || _FILE_OFFSET_BITS != 64
  49 #ifdef __STDC__
  50 #include <libelf.h>
  51 extern uint_t   ld_version(uint_t);
  52 extern void     ld_input_done(uint_t *);
  53 
  54 extern void     ld_start(const char *, const Elf32_Half, const char *);
  55 extern void     ld_atexit(int);
  56 extern void     ld_open(const char **, const char **, int *, int, Elf **,
  57                         Elf *, size_t, const Elf_Kind);
  58 extern void     ld_file(const char *, const Elf_Kind, int, Elf *);
  59 extern void     ld_input_section(const char *, Elf32_Shdr **, Elf32_Word,
  60                         Elf_Data *, Elf *, uint_t *);
  61 extern void     ld_section(const char *, Elf32_Shdr *, Elf32_Word,
  62                         Elf_Data *, Elf *);
  63 
  64 #if defined(_LP64) || defined(_LONGLONG_TYPE)
  65 extern void     ld_start64(const char *, const Elf64_Half, const char *);
  66 extern void     ld_atexit64(int);
  67 extern void     ld_open64(const char **, const char **, int *, int, Elf **,
  68                         Elf *, size_t, const Elf_Kind);
  69 extern void     ld_file64(const char *, const Elf_Kind, int, Elf *);
  70 extern void     ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word,
  71                         Elf_Data *, Elf *, uint_t *);
  72 extern void     ld_section64(const char *, Elf64_Shdr *, Elf64_Word,
  73                         Elf_Data *, Elf *);
  74 
  75 #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
  76 #else
  77 extern void     ld_version();
  78 extern void     ld_input_done();
  79 
  80 extern void     ld_start();
  81 extern void     ld_atexit();
  82 extern void     ld_open();
  83 extern void     ld_file();
  84 extern void     ld_input_section();
  85 extern void     ld_section();
  86 
  87 #if defined(_LP64) || defined(_LONGLONG_TYPE)
  88 extern void     ld_start64();
  89 extern void     ld_atexit64();
  90 extern void     ld_open64();
  91 extern void     ld_file64();
  92 extern void     ld_input_section64();
  93 extern void     ld_section64();
  94 
  95 #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
  96 #endif /* __STDC__ */
  97 #endif /* !defined(_ILP32) || _FILE_OFFSET_BITS != 64 */
  98 
  99 /*
 100  * ld_version() version values.
 101  */
 102 #define LD_SUP_VNONE    0
 103 #define LD_SUP_VERSION1 1
 104 #define LD_SUP_VERSION2 2
 105 #define LD_SUP_VERSION3 3
 106 #define LD_SUP_VCURRENT LD_SUP_VERSION3
 107 
 108 /*
 109  * Flags passed to ld support calls.
 110  */
 111 #define LD_SUP_DERIVED          0x1     /* derived filename */
 112 #define LD_SUP_INHERITED        0x2     /* file inherited from .so DT_NEEDED */
 113 #define LD_SUP_EXTRACTED        0x4     /* file extracted from archive */
 114 #endif
 115 
 116 /*


 207         lagreg_t        lr_r8;      /* arg5 */
 208         lagreg_t        lr_r9;      /* arg6 */
 209 } La_amd64_regs;
 210 #else
 211 typedef struct _la_sparc_regs   La_sparcv8_regs;
 212 typedef struct {
 213         lagreg_t        lr_esp;
 214         lagreg_t        lr_ebp;
 215 } La_i86_regs;
 216 #endif
 217 
 218 #if     !defined(_SYS_INT_TYPES_H)
 219 #if     defined(_LP64) || defined(_I32LPx)
 220 typedef unsigned long           uintptr_t;
 221 #else
 222 typedef unsigned int            uintptr_t;
 223 #endif
 224 #endif
 225 
 226 
 227 #ifdef  __STDC__
 228 extern uint_t           la_version(uint_t);
 229 extern void             la_activity(uintptr_t *, uint_t);
 230 extern void             la_preinit(uintptr_t *);
 231 extern char             *la_objsearch(const char *, uintptr_t *, uint_t);
 232 extern uint_t           la_objopen(Link_map *, Lmid_t, uintptr_t *);
 233 extern uint_t           la_objclose(uintptr_t *);
 234 extern int              la_objfilter(uintptr_t *, const char *, uintptr_t *,
 235                                 uint_t);
 236 #if     defined(_LP64)
 237 extern uintptr_t        la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
 238                                 uintptr_t *, La_amd64_regs *,   uint_t *,
 239                                 const char *);
 240 extern uintptr_t        la_symbind64(Elf64_Sym *, uint_t, uintptr_t *,
 241                                 uintptr_t *, uint_t *, const char *);
 242 extern uintptr_t        la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
 243                                 uintptr_t *, La_sparcv9_regs *, uint_t *,
 244                                 const char *);
 245 extern uintptr_t        la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *,
 246                                 uintptr_t *, uintptr_t, const char *);
 247 #else  /* !defined(_LP64) */
 248 extern uintptr_t        la_symbind32(Elf32_Sym *, uint_t, uintptr_t *,
 249                                 uintptr_t *, uint_t *);
 250 extern uintptr_t        la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
 251                                 uintptr_t *, La_sparcv8_regs *, uint_t *);
 252 extern uintptr_t        la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
 253                                 uintptr_t *, La_i86_regs *, uint_t *);
 254 extern uintptr_t        la_pltexit(Elf32_Sym *, uint_t, uintptr_t *,
 255                                 uintptr_t *, uintptr_t);
 256 #endif /* _LP64 */
 257 #else  /* __STDC__ */
 258 extern uint_t           la_version();
 259 extern void             la_preinit();
 260 extern uint_t           la_objopen();
 261 extern uint_t           la_objclose();
 262 extern int              la_objfilter();
 263 #if     defined(_LP64)
 264 extern uintptr_t        la_sparcv9_pltenter();
 265 extern uintptr_t        la_pltexit64();
 266 extern uintptr_t        la_symbind64();
 267 #else  /* _ILP32 */
 268 extern uintptr_t        la_sparcv8_pltenter();
 269 extern uintptr_t        la_i86_pltenter();
 270 extern uintptr_t        la_pltexit();
 271 extern uintptr_t        la_symbind32();
 272 #endif /* _LP64 */
 273 #endif /* __STDC__ */
 274 
 275 #ifdef  __STDC__
 276 /*
 277  * The ElfW() macro is a GNU/Linux feature, provided as support for
 278  * the dl_phdr_info structure used by dl_phdr_iterate(), which also
 279  * originated under Linux. Given an ELF data type, without the ElfXX_
 280  * prefix, it supplies the appropriate prefix (Elf32_ or Elf64_) for
 281  * the ELFCLASS of the code being compiled.
 282  *
 283  * Note that ElfW() is not suitable in situations in which the ELFCLASS
 284  * of the code being compiled does not match that of the objects that
 285  * code is intended to operate on (e.g. a 32-bit link-editor building
 286  * a 64-bit object). The macros defined in <sys/machelf.h> are
 287  * recommended in such cases.
 288  */
 289 #ifdef _LP64
 290 #define ElfW(type)      Elf64_ ## type
 291 #else
 292 #define ElfW(type)      Elf32_ ## type
 293 #endif
 294 
 295 /*


 309         const char              *dlpi_name;     /* Null-terminated obj name */
 310         const ElfW(Phdr)        *dlpi_phdr;     /* Ptr to ELF program hdr arr */
 311         ElfW(Half)              dlpi_phnum;     /* # of items in dlpi_phdr[] */
 312 
 313         /*
 314          * Note: Following members were introduced after the first version
 315          * of this structure was available.  The dl_iterate_phdr() callback
 316          * function is passed a 'size' argument giving the size of the info
 317          * structure, and must compare that size to the offset of these fields
 318          * before accessing them to ensure that they are present.
 319          */
 320 
 321         /* Incremented when a new object is mapped into the process */
 322         u_longlong_t            dlpi_adds;
 323         /* Incremented when an object is unmapped from the process */
 324         u_longlong_t            dlpi_subs;
 325 };
 326 
 327 extern  int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
 328             void *);
 329 #endif /* __STDC__ */
 330 
 331 #endif  /* _ASM */
 332 #endif /* _KERNEL */
 333 
 334 
 335 #ifdef __cplusplus
 336 }
 337 #endif
 338 
 339 #endif  /* _LINK_H */


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #ifndef _LINK_H
  27 #define _LINK_H
  28 
  29 #include <sys/link.h>
  30 
  31 #ifndef _ASM
  32 #include <elf.h>
  33 #include <sys/types.h>
  34 #include <dlfcn.h>
  35 #endif
  36 
  37 #ifdef  __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 #ifndef _ASM
  42 /*
  43  * ld support library calls.
  44  *
  45  * These cannot be used in a 32bit large file capable environment because
  46  * libelf is not large-file safe.  Only define these interfaces if we are not
  47  * 32bit, or not in the large file environment.
  48  */
  49 #if !defined(_ILP32) || _FILE_OFFSET_BITS != 64

  50 #include <libelf.h>
  51 extern uint_t   ld_version(uint_t);
  52 extern void     ld_input_done(uint_t *);
  53 
  54 extern void     ld_start(const char *, const Elf32_Half, const char *);
  55 extern void     ld_atexit(int);
  56 extern void     ld_open(const char **, const char **, int *, int, Elf **,
  57                         Elf *, size_t, const Elf_Kind);
  58 extern void     ld_file(const char *, const Elf_Kind, int, Elf *);
  59 extern void     ld_input_section(const char *, Elf32_Shdr **, Elf32_Word,
  60                         Elf_Data *, Elf *, uint_t *);
  61 extern void     ld_section(const char *, Elf32_Shdr *, Elf32_Word,
  62                         Elf_Data *, Elf *);
  63 
  64 #if defined(_LP64) || defined(_LONGLONG_TYPE)
  65 extern void     ld_start64(const char *, const Elf64_Half, const char *);
  66 extern void     ld_atexit64(int);
  67 extern void     ld_open64(const char **, const char **, int *, int, Elf **,
  68                         Elf *, size_t, const Elf_Kind);
  69 extern void     ld_file64(const char *, const Elf_Kind, int, Elf *);
  70 extern void     ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word,
  71                         Elf_Data *, Elf *, uint_t *);
  72 extern void     ld_section64(const char *, Elf64_Shdr *, Elf64_Word,
  73                         Elf_Data *, Elf *);
  74 
  75 #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */





















  76 #endif /* !defined(_ILP32) || _FILE_OFFSET_BITS != 64 */
  77 
  78 /*
  79  * ld_version() version values.
  80  */
  81 #define LD_SUP_VNONE    0
  82 #define LD_SUP_VERSION1 1
  83 #define LD_SUP_VERSION2 2
  84 #define LD_SUP_VERSION3 3
  85 #define LD_SUP_VCURRENT LD_SUP_VERSION3
  86 
  87 /*
  88  * Flags passed to ld support calls.
  89  */
  90 #define LD_SUP_DERIVED          0x1     /* derived filename */
  91 #define LD_SUP_INHERITED        0x2     /* file inherited from .so DT_NEEDED */
  92 #define LD_SUP_EXTRACTED        0x4     /* file extracted from archive */
  93 #endif
  94 
  95 /*


 186         lagreg_t        lr_r8;      /* arg5 */
 187         lagreg_t        lr_r9;      /* arg6 */
 188 } La_amd64_regs;
 189 #else
 190 typedef struct _la_sparc_regs   La_sparcv8_regs;
 191 typedef struct {
 192         lagreg_t        lr_esp;
 193         lagreg_t        lr_ebp;
 194 } La_i86_regs;
 195 #endif
 196 
 197 #if     !defined(_SYS_INT_TYPES_H)
 198 #if     defined(_LP64) || defined(_I32LPx)
 199 typedef unsigned long           uintptr_t;
 200 #else
 201 typedef unsigned int            uintptr_t;
 202 #endif
 203 #endif
 204 
 205 

 206 extern uint_t           la_version(uint_t);
 207 extern void             la_activity(uintptr_t *, uint_t);
 208 extern void             la_preinit(uintptr_t *);
 209 extern char             *la_objsearch(const char *, uintptr_t *, uint_t);
 210 extern uint_t           la_objopen(Link_map *, Lmid_t, uintptr_t *);
 211 extern uint_t           la_objclose(uintptr_t *);
 212 extern int              la_objfilter(uintptr_t *, const char *, uintptr_t *,
 213                                 uint_t);
 214 #if     defined(_LP64)
 215 extern uintptr_t        la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
 216                                 uintptr_t *, La_amd64_regs *,   uint_t *,
 217                                 const char *);
 218 extern uintptr_t        la_symbind64(Elf64_Sym *, uint_t, uintptr_t *,
 219                                 uintptr_t *, uint_t *, const char *);
 220 extern uintptr_t        la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
 221                                 uintptr_t *, La_sparcv9_regs *, uint_t *,
 222                                 const char *);
 223 extern uintptr_t        la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *,
 224                                 uintptr_t *, uintptr_t, const char *);
 225 #else  /* !defined(_LP64) */
 226 extern uintptr_t        la_symbind32(Elf32_Sym *, uint_t, uintptr_t *,
 227                                 uintptr_t *, uint_t *);
 228 extern uintptr_t        la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
 229                                 uintptr_t *, La_sparcv8_regs *, uint_t *);
 230 extern uintptr_t        la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
 231                                 uintptr_t *, La_i86_regs *, uint_t *);
 232 extern uintptr_t        la_pltexit(Elf32_Sym *, uint_t, uintptr_t *,
 233                                 uintptr_t *, uintptr_t);
 234 #endif /* _LP64 */

















 235 

 236 /*
 237  * The ElfW() macro is a GNU/Linux feature, provided as support for
 238  * the dl_phdr_info structure used by dl_phdr_iterate(), which also
 239  * originated under Linux. Given an ELF data type, without the ElfXX_
 240  * prefix, it supplies the appropriate prefix (Elf32_ or Elf64_) for
 241  * the ELFCLASS of the code being compiled.
 242  *
 243  * Note that ElfW() is not suitable in situations in which the ELFCLASS
 244  * of the code being compiled does not match that of the objects that
 245  * code is intended to operate on (e.g. a 32-bit link-editor building
 246  * a 64-bit object). The macros defined in <sys/machelf.h> are
 247  * recommended in such cases.
 248  */
 249 #ifdef _LP64
 250 #define ElfW(type)      Elf64_ ## type
 251 #else
 252 #define ElfW(type)      Elf32_ ## type
 253 #endif
 254 
 255 /*


 269         const char              *dlpi_name;     /* Null-terminated obj name */
 270         const ElfW(Phdr)        *dlpi_phdr;     /* Ptr to ELF program hdr arr */
 271         ElfW(Half)              dlpi_phnum;     /* # of items in dlpi_phdr[] */
 272 
 273         /*
 274          * Note: Following members were introduced after the first version
 275          * of this structure was available.  The dl_iterate_phdr() callback
 276          * function is passed a 'size' argument giving the size of the info
 277          * structure, and must compare that size to the offset of these fields
 278          * before accessing them to ensure that they are present.
 279          */
 280 
 281         /* Incremented when a new object is mapped into the process */
 282         u_longlong_t            dlpi_adds;
 283         /* Incremented when an object is unmapped from the process */
 284         u_longlong_t            dlpi_subs;
 285 };
 286 
 287 extern  int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
 288             void *);

 289 
 290 #endif  /* _ASM */
 291 #endif /* _KERNEL */
 292 
 293 
 294 #ifdef __cplusplus
 295 }
 296 #endif
 297 
 298 #endif  /* _LINK_H */