Home | History | Annotate | Download | only in sanitizer_common
      1 //===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file is a part of Sanitizer runtime. It contains FreeBSD-specific
     11 // definitions.
     12 //
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef SANITIZER_FREEBSD_H
     16 #define SANITIZER_FREEBSD_H
     17 
     18 #include "sanitizer_internal_defs.h"
     19 
     20 // x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
     21 // 32-bit mode.
     22 #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
     23 # include <osreldate.h>
     24 # if __FreeBSD_version <= 902001  // v9.2
     25 #  include <link.h>
     26 #  include <sys/param.h>
     27 #  include <ucontext.h>
     28 
     29 namespace __sanitizer {
     30 
     31 typedef unsigned long long __xuint64_t;
     32 
     33 typedef __int32_t __xregister_t;
     34 
     35 typedef struct __xmcontext {
     36   __xregister_t mc_onstack;
     37   __xregister_t mc_gs;
     38   __xregister_t mc_fs;
     39   __xregister_t mc_es;
     40   __xregister_t mc_ds;
     41   __xregister_t mc_edi;
     42   __xregister_t mc_esi;
     43   __xregister_t mc_ebp;
     44   __xregister_t mc_isp;
     45   __xregister_t mc_ebx;
     46   __xregister_t mc_edx;
     47   __xregister_t mc_ecx;
     48   __xregister_t mc_eax;
     49   __xregister_t mc_trapno;
     50   __xregister_t mc_err;
     51   __xregister_t mc_eip;
     52   __xregister_t mc_cs;
     53   __xregister_t mc_eflags;
     54   __xregister_t mc_esp;
     55   __xregister_t mc_ss;
     56 
     57   int mc_len;
     58   int mc_fpformat;
     59   int mc_ownedfp;
     60   __xregister_t mc_flags;
     61 
     62   int mc_fpstate[128] __aligned(16);
     63   __xregister_t mc_fsbase;
     64   __xregister_t mc_gsbase;
     65   __xregister_t mc_xfpustate;
     66   __xregister_t mc_xfpustate_len;
     67 
     68   int mc_spare2[4];
     69 } xmcontext_t;
     70 
     71 typedef struct __xucontext {
     72   sigset_t  uc_sigmask;
     73   xmcontext_t  uc_mcontext;
     74 
     75   struct __ucontext *uc_link;
     76   stack_t uc_stack;
     77   int uc_flags;
     78   int __spare__[4];
     79 } xucontext_t;
     80 
     81 struct xkinfo_vmentry {
     82   int kve_structsize;
     83   int kve_type;
     84   __xuint64_t kve_start;
     85   __xuint64_t kve_end;
     86   __xuint64_t kve_offset;
     87   __xuint64_t kve_vn_fileid;
     88   __uint32_t kve_vn_fsid;
     89   int kve_flags;
     90   int kve_resident;
     91   int kve_private_resident;
     92   int kve_protection;
     93   int kve_ref_count;
     94   int kve_shadow_count;
     95   int kve_vn_type;
     96   __xuint64_t kve_vn_size;
     97   __uint32_t kve_vn_rdev;
     98   __uint16_t kve_vn_mode;
     99   __uint16_t kve_status;
    100   int _kve_ispare[12];
    101   char kve_path[PATH_MAX];
    102 };
    103 
    104 typedef struct {
    105   __uint32_t p_type;
    106   __uint32_t p_offset;
    107   __uint32_t p_vaddr;
    108   __uint32_t p_paddr;
    109   __uint32_t p_filesz;
    110   __uint32_t p_memsz;
    111   __uint32_t p_flags;
    112   __uint32_t p_align;
    113 } XElf32_Phdr;
    114 
    115 struct xdl_phdr_info {
    116   Elf_Addr dlpi_addr;
    117   const char *dlpi_name;
    118   const XElf32_Phdr *dlpi_phdr;
    119   Elf_Half dlpi_phnum;
    120   unsigned long long int dlpi_adds;
    121   unsigned long long int dlpi_subs;
    122   size_t dlpi_tls_modid;
    123   void *dlpi_tls_data;
    124 };
    125 
    126 typedef int (*__xdl_iterate_hdr_callback)(struct xdl_phdr_info*, size_t, void*);
    127 typedef int xdl_iterate_phdr_t(__xdl_iterate_hdr_callback, void*);
    128 
    129 #define xdl_iterate_phdr(callback, param) \
    130   (((xdl_iterate_phdr_t*) dl_iterate_phdr)((callback), (param)))
    131 
    132 }  // namespace __sanitizer
    133 
    134 # endif  // __FreeBSD_version <= 902001
    135 #endif  // SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
    136 
    137 #endif  // SANITIZER_FREEBSD_H
    138