Ubuntu系统gcc6.3.0使用patch安装补丁

1 文件及信息获取

1.0文件目录

├── ubuntu_model
│   ├── add.patch
│   ├── first
│   │   ├── sanitizer_linux.cc
│   │   └── sanitizer_linux.h
│   ├── mulit_add.patch
│   └── second
│       ├── sanitizer_linux.cc
│       └── sanitizer_linux.h

1.2 文件内容

first/sanitizer_linux.h

//===-- sanitizer_linux.h ---------------------------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Linux-specific syscall wrappers and classes.
//
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_LINUX_H
#define SANITIZER_LINUX_H

#include "sanitizer_platform.h"
#if SANITIZER_FREEBSD || SANITIZER_LINUX
#include "sanitizer_common.h"
#include "sanitizer_internal_defs.h"
#include "sanitizer_posix.h"
#include "sanitizer_platform_limits_posix.h"
struct link_map;  // Opaque type returned by dlopen().
struct sigaltstack;

namespace __sanitizer {
// Dirent structure for getdents(). Note that this structure is different from
// the one in <dirent.h>, which is used by readdir().
struct linux_dirent;

// Syscall wrappers.
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
uptr internal_sigaltstack(const struct sigaltstack* ss,
                          struct sigaltstack* oss);
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
    __sanitizer_sigset_t *oldset);
void internal_sigfillset(__sanitizer_sigset_t *set);

// Linux-only syscalls.
#if SANITIZER_LINUX
uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5);
// Used only by sanitizer_stoptheworld. Signal handlers that are actually used
// (like the process-wide error reporting SEGV handler) must use
// internal_sigaction instead.
int internal_sigaction_norestorer(int signum, const void *act, void *oldact);
void internal_sigdelset(__sanitizer_sigset_t *set, int signum);
#if defined(__x86_64__) || defined(__mips__) || defined(__aarch64__)
uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
                    int *parent_tidptr, void *newtls, int *child_tidptr);
#endif
#endif  // SANITIZER_LINUX

// This class reads thread IDs from /proc/<pid>/task using only syscalls.
class ThreadLister {
 public:
  explicit ThreadLister(int pid);
  ~ThreadLister();
  // GetNextTID returns -1 if the list of threads is exhausted, or if there has
  // been an error.
  int GetNextTID();
  void Reset();
  bool error();

 private:
  bool GetDirectoryEntries();

  int pid_;
  int descriptor_;
  InternalScopedBuffer<char> buffer_;
  bool error_;
  struct linux_dirent* entry_;
  int bytes_read_;
};

// Exposed for testing.
uptr ThreadDescriptorSize();
uptr ThreadSelf();
uptr ThreadSelfOffset();

// Matches a library's file name against a base name (stripping path and version
// information).
bool LibraryNameIs(const char *full_name, const char *base_name);

// Call cb for each region mapped by map.
void ForEachMappedRegion(link_map *map, void (*cb)(const void *, uptr));
}  // namespace __sanitizer

#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX
#endif  // SANITIZER_LINUX_H

second/sanitizer_linux.h

//===-- sanitizer_linux.h ---------------------------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Linux-specific syscall wrappers and classes.
//
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_LINUX_H
#define SANITIZER_LINUX_H

#include "sanitizer_platform.h"
#if SANITIZER_FREEBSD || SANITIZER_LINUX
#include "sanitizer_common.h"
#include "sanitizer_internal_defs.h"
#include "sanitizer_posix.h"
#include "sanitizer_platform_limits_posix.h"
#include <sys/ucontext.h>
struct link_map;  // Opaque type returned by dlopen().
struct sigaltstack;

namespace __sanitizer {
// Dirent structure for getdents(). Note that this structure is different from
// the one in <dirent.h>, which is used by readdir().
struct linux_dirent;

// Syscall wrappers.
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
uptr internal_sigaltstack(const struct stack_t* ss,
                          struct stack_t* oss);
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
    __sanitizer_sigset_t *oldset);
void internal_sigfillset(__sanitizer_sigset_t *set);

// Linux-only syscalls.
#if SANITIZER_LINUX
uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5);
// Used only by sanitizer_stoptheworld. Signal handlers that are actually used
// (like the process-wide error reporting SEGV handler) must use
// internal_sigaction instead.
int internal_sigaction_norestorer(int signum, const void *act, void *oldact);
void internal_sigdelset(__sanitizer_sigset_t *set, int signum);
#if defined(__x86_64__) || defined(__mips__) || defined(__aarch64__)
uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
                    int *parent_tidptr, void *newtls, int *child_tidptr);
#endif
#endif  // SANITIZER_LINUX

// This class reads thread IDs from /proc/<pid>/task using only syscalls.
class ThreadLister {
 public:
  explicit ThreadLister(int pid);
  ~ThreadLister();
  // GetNextTID returns -1 if the list of threads is exhausted, or if there has
  // been an error.
  int GetNextTID();
  void Reset();
  bool error();

 private:
  bool GetDirectoryEntries();

  int pid_;
  int descriptor_;
  InternalScopedBuffer<char> buffer_;
  bool error_;
  struct linux_dirent* entry_;
  int bytes_read_;
};

// Exposed for testing.
uptr ThreadDescriptorSize();
uptr ThreadSelf();
uptr ThreadSelfOffset();

// Matches a library's file name against a base name (stripping path and version
// information).
bool LibraryNameIs(const char *full_name, const char *base_name);

// Call cb for each region mapped by map.
void ForEachMappedRegion(link_map *map, void (*cb)(const void *, uptr));
}  // namespace __sanitizer

#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX
#endif  // SANITIZER_LINUX_H

1.3 查看文件差异信息

获取差异信息

git diff first/sanitizer_linux.h second/sanitizer_linux.h
  • Result
diff --git a/first/sanitizer_linux.h b/second/sanitizer_linux.h
index 8991b6d..9b09d27 100644
--- a/first/sanitizer_linux.h
+++ b/second/sanitizer_linux.h
@@ -17,6 +17,7 @@
 #include "sanitizer_internal_defs.h"
 #include "sanitizer_posix.h"
 #include "sanitizer_platform_limits_posix.h"
+#include <sys/ucontext.h>
 struct link_map;  // Opaque type returned by dlopen().
 struct sigaltstack;
 
@@ -27,8 +28,8 @@ struct linux_dirent;
 
 // Syscall wrappers.
 uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
-                          struct sigaltstack* oss);
+uptr internal_sigaltstack(const struct stack_t* ss,
+                          struct stack_t* oss);
 uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
     __sanitizer_sigset_t *oldset);
 void internal_sigfillset(__sanitizer_sigset_t *set);
  • Analysis
内容描述
diff --git a/first/sanitizer_linux.h b/second/sanitizer_linux.h比较a/first/sanitizer_linux.h和b/second/sanitizer_linux.h文件的内容差异;
index 8991b6d…9b09d27 100644100644表示文件属性权限;
— a/first/sanitizer_linux.h—表示低版本(旧)文件;
+++ b/second/sanitizer_linux.h+++表示高版本(新)文件;
@@ -17,6 +17,7 @@-17,6中的-表示低版本文件,17表示该文件的第17行,6表示从第17行开始显示6行数据;+17,7中+表示高版本文件,17表示该文件的第17行,7表示从第17行开始显示7行数据;
+#include <sys/ucontext.h>+表示新增的数据;
-uptr internal_sigaltstack(const struct sigaltstack* ss,struct sigaltstack* oss);表示低版本数据,修改前的数据
+uptr internal_sigaltstack(const struct stack_t* ss,struct stack_t* oss);表示高版本数据,修改后的数据

退出:q

2 创建及安装补丁

2.1 单文件

创建补丁

diff -uN first/sanitizer_linux.h second/sanitizer_linux.h > add.patch

查看补丁

more add.patch
--- first/sanitizer_linux.h	2019-04-20 14:51:40.115514670 +0800
+++ second/sanitizer_linux.h	2019-04-20 14:51:37.819561447 +0800
@@ -17,8 +17,8 @@
 #include "sanitizer_internal_defs.h"
 #include "sanitizer_posix.h"
 #include "sanitizer_platform_limits_posix.h"
+#include <sys/ucontext.h>
 struct link_map;  // Opaque type returned by dlopen().
-struct sigaltstack;
 
 namespace __sanitizer {
 // Dirent structure for getdents(). Note that this structure is different from
@@ -27,8 +27,8 @@
 
 // Syscall wrappers.
 uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
-                          struct sigaltstack* oss);
+uptr internal_sigaltstack(const struct stack_t* ss,
+                          struct stack_t* oss);
 uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
     __sanitizer_sigset_t *oldset);
 void internal_sigfillset(__sanitizer_sigset_t *set);

安装补丁

patch -p0 < add.patch

2.2 多文件

创建补丁

diff -uNr first/ second/ > multi_add.patch

查看补丁

more multi_add.patch
diff -uNr first/sanitizer_linux.cc second/sanitizer_linux.cc
--- first/sanitizer_linux.cc	2019-04-20 17:19:15.615867823 +0800
+++ second/sanitizer_linux.cc	2019-04-20 17:21:49.725074548 +0800
@@ -546,8 +546,8 @@
 }
 #endif
 
-uptr internal_sigaltstack(const struct sigaltstack *ss,
-                         struct sigaltstack *oss) {
+uptr internal_sigaltstack(const stack_t *ss,
+                         stack_t *oss) {
   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
 }
 
diff -uNr first/sanitizer_linux.h second/sanitizer_linux.h
--- first/sanitizer_linux.h	2019-04-20 16:32:49.936079963 +0800
+++ second/sanitizer_linux.h	2019-04-20 14:51:37.819561447 +0800
@@ -17,8 +17,8 @@
 #include "sanitizer_internal_defs.h"
 #include "sanitizer_posix.h"
 #include "sanitizer_platform_limits_posix.h"
+#include <sys/ucontext.h>
 struct link_map;  // Opaque type returned by dlopen().
-struct sigaltstack;
 
 namespace __sanitizer {
 // Dirent structure for getdents(). Note that this structure is different from
@@ -27,8 +27,8 @@
 
 // Syscall wrappers.
 uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
-                          struct sigaltstack* oss);
+uptr internal_sigaltstack(const struct stack_t* ss,
+                          struct stack_t* oss);
 uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
     __sanitizer_sigset_t *oldset);
 void internal_sigfillset(__sanitizer_sigset_t *set);

安装补丁

patch -p0 < multi_add.patch

3 解除补丁

单文件解除

patch -RE -p0 < add.patch

多文件解除

patch -R -p0 < add.patch

到此基础操作技能已经介绍完毕,下面开始查找变动文件,并进行修改.


1 变动的文件目录

libgcc/config/aarch64/linux-unwind.h 
 libgcc/config/alpha/linux-unwind.h 
 libgcc/config/bfin/linux-unwind.h    
 libgcc/config/i386/linux-unwind.h     
 libgcc/config/m68k/linux-unwind.h    
 libgcc/config/mips/linux-unwind.h     
 libgcc/config/nios2/linux-unwind.h     
 libgcc/config/pa/linux-unwind.h       
 libgcc/config/sh/linux-unwind.h         
 libgcc/config/tilepro/linux-unwind.h      
 libgcc/config/xtensa/linux-unwind.h         
 libjava/include/i386-signal.h                     
 libjava/include/s390-signal.h                          
 libjava/include/sh-signal.h                              
 libjava/include/x86_64-signal.h                           
 libsanitizer/sanitizer_common/sanitizer_linux.cc                
 libsanitizer/sanitizer_common/sanitizer_linux.h                 
 .../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc     
 libsanitizer/tsan/tsan_interceptors.cc                            
 libsanitizer/tsan/tsan_platform_linux.cc                        
 

2 比较变动信息

2.1 创建补丁

diff -uNr first/ second/ > new_multi.patch

2.2 变动信息

diff -uNr first/aarch64_linux-unwind.h second/aarch64_linux-unwind.h
--- first/aarch64_linux-unwind.h	2019-04-22 09:55:50.288366978 +0800
+++ second/aarch64_linux-unwind.h	2019-04-22 09:55:45.984442430 +0800
@@ -52,7 +52,7 @@
   struct rt_sigframe
   {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
   };
 
   struct rt_sigframe *rt_;
diff -uNr first/alpha_linux-unwind.h second/alpha_linux-unwind.h
--- first/alpha_linux-unwind.h	2019-04-22 09:25:01.823598641 +0800
+++ second/alpha_linux-unwind.h	2019-04-22 09:56:52.071281641 +0800
@@ -51,7 +51,7 @@
     {
       struct rt_sigframe {
 	siginfo_t info;
-	struct ucontext uc;
+	ucontext_t uc;
       } *rt_ = context->cfa;
       sc = &rt_->uc.uc_mcontext;
     }
diff -uNr first/bfin_linux-unwind.h second/bfin_linux-unwind.h
--- first/bfin_linux-unwind.h	2019-04-22 09:25:31.759664245 +0800
+++ second/bfin_linux-unwind.h	2019-04-22 09:58:00.070082724 +0800
@@ -52,7 +52,7 @@
 	void *puc;
 	char retcode[8];
 	siginfo_t info;
-	struct ucontext uc;
+	ucontext_t uc;
       } *rt_ = context->cfa;
 
       /* The void * cast is necessary to avoid an aliasing warning.
diff -uNr first/i386_linux-unwind.h second/i386_linux-unwind.h
--- first/i386_linux-unwind.h	2019-04-22 09:26:40.399686087 +0800
+++ second/i386_linux-unwind.h	2019-04-22 10:01:15.770611404 +0800
@@ -58,7 +58,7 @@
   if (*(unsigned char *)(pc+0) == 0x48
       && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
     {
-      struct ucontext_t *uc_ = context->cfa;
+      ucontext_t *uc_ = context->cfa;
       /* The void * cast is necessary to avoid an aliasing warning.
          The aliasing warning is correct, but should not be a problem
          because it does not alias anything.  */
@@ -138,7 +138,7 @@
 	siginfo_t *pinfo;
 	void *puc;
 	siginfo_t info;
-	struct ucontext uc;
+	ucontext_t uc;
       } *rt_ = context->cfa;
       /* The void * cast is necessary to avoid an aliasing warning.
          The aliasing warning is correct, but should not be a problem
diff -uNr first/i386-signal.h second/i386-signal.h
--- first/i386-signal.h	2019-04-22 09:12:15.652608838 +0800
+++ second/i386-signal.h	2019-04-22 10:27:25.870348758 +0800
@@ -29,7 +29,7 @@
 #define HANDLE_DIVIDE_OVERFLOW						\
 do									\
 {									\
-  struct ucontext *_uc = (struct ucontext *)_p;				\
+  ucontext_t *_uc = (ucontext_t *)_p;				\
   gregset_t &_gregs = _uc->uc_mcontext.gregs;				\
   unsigned char *_eip = (unsigned char *)_gregs[REG_EIP];		\
 									\
diff -uNr first/m68k_linux-unwind.h second/m68k_linux-unwind.h
--- first/m68k_linux-unwind.h	2019-04-22 09:27:36.979582350 +0800
+++ second/m68k_linux-unwind.h	2019-04-22 10:01:52.061964878 +0800
@@ -33,7 +33,7 @@
 /* <sys/ucontext.h> is unfortunately broken right now.  */
 struct uw_ucontext {
 	unsigned long	  uc_flags;
-	struct ucontext  *uc_link;
+	ucontext_t  *uc_link;
 	stack_t		  uc_stack;
 	mcontext_t	  uc_mcontext;
 	unsigned long	  uc_filler[80];
diff -uNr first/mips_linux-unwind.h second/mips_linux-unwind.h
--- first/mips_linux-unwind.h	2019-04-22 09:28:21.911429845 +0800
+++ second/mips_linux-unwind.h	2019-04-22 10:03:41.044019183 +0800
@@ -31,7 +31,8 @@
 
 /* The third parameter to the signal handler points to something with
  * this structure defined in asm/ucontext.h, but the name clashes with
- * struct ucontext from sys/ucontext.h so this private copy is used.  */
+ * ucontext_t from sys/ucontext.h so this private copy is used.  */
+
 typedef struct _sig_ucontext {
     unsigned long         uc_flags;
     struct _sig_ucontext  *uc_link;
diff -uNr first/nios2_linux-unwind.h second/nios2_linux-unwind.h
--- first/nios2_linux-unwind.h	2019-04-22 09:28:54.235284961 +0800
+++ second/nios2_linux-unwind.h	2019-04-22 10:04:07.039554245 +0800
@@ -38,7 +38,7 @@
 
 struct nios2_ucontext {
   unsigned long uc_flags;
-  struct ucontext *uc_link;
+  ucontext_t *uc_link;
   stack_t uc_stack;
   struct nios2_mcontext uc_mcontext;
   sigset_t uc_sigmask;	/* mask last for extensibility */
diff -uNr first/pa_linux-unwind.h second/pa_linux-unwind.h
--- first/pa_linux-unwind.h	2019-04-22 09:29:41.199026088 +0800
+++ second/pa_linux-unwind.h	2019-04-22 10:04:44.618881622 +0800
@@ -80,7 +80,7 @@
   struct sigcontext *sc;
   struct rt_sigframe {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
   } *frame;
 
   /* rt_sigreturn trampoline:
diff -uNr first/s390-signal.h second/s390-signal.h
--- first/s390-signal.h	2019-04-22 09:12:47.374449857 +0800
+++ second/s390-signal.h	2019-04-22 10:11:54.191161431 +0800
@@ -51,7 +51,7 @@
   struct                                                                \
   {                                                                     \
     unsigned long int uc_flags;                                         \
-    struct ucontext *uc_link;                                           \
+    ucontext_t *uc_link;                                           \
     stack_t uc_stack;                                                   \
     mcontext_t uc_mcontext;                                             \
     unsigned long sigmask[2];                                           \
diff -uNr first/sanitizer_linux.cc second/sanitizer_linux.cc
--- first/sanitizer_linux.cc	2019-04-20 17:34:33.758599209 +0800
+++ second/sanitizer_linux.cc	2019-04-22 10:16:04.846639694 +0800
@@ -546,8 +546,8 @@
 }
 #endif
 
-uptr internal_sigaltstack(const struct sigaltstack *ss,
-                         struct sigaltstack *oss) {
+uptr internal_sigaltstack(const stack_t *ss,
+                         stack_t *oss) {
   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
 }
 
diff -uNr first/sanitizer_linux.h second/sanitizer_linux.h
--- first/sanitizer_linux.h	2019-04-20 17:34:33.874598153 +0800
+++ second/sanitizer_linux.h	2019-04-22 10:15:44.735002792 +0800
@@ -17,8 +17,8 @@
 #include "sanitizer_internal_defs.h"
 #include "sanitizer_posix.h"
 #include "sanitizer_platform_limits_posix.h"
+#include<sys/ucontext.h>
 struct link_map;  // Opaque type returned by dlopen().
-struct sigaltstack;
 
 namespace __sanitizer {
 // Dirent structure for getdents(). Note that this structure is different from
@@ -27,8 +27,8 @@
 
 // Syscall wrappers.
 uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
-                          struct sigaltstack* oss);
+uptr internal_sigaltstack(const stack_t* ss,
+                          stack_t* oss);
 uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
     __sanitizer_sigset_t *oldset);
 void internal_sigfillset(__sanitizer_sigset_t *set);
diff -uNr first/sanitizer_stoptheworld_linux_libcdep.cc second/sanitizer_stoptheworld_linux_libcdep.cc
--- first/sanitizer_stoptheworld_linux_libcdep.cc	2019-04-22 10:17:48.732763483 +0800
+++ second/sanitizer_stoptheworld_linux_libcdep.cc	2019-04-22 09:09:23.255349000 +0800
@@ -267,7 +267,7 @@
 
   // Alternate stack for signal handling.
   InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
-  struct sigaltstack handler_stack;
+  stack_t handler_stack;
   internal_memset(&handler_stack, 0, sizeof(handler_stack));
   handler_stack.ss_sp = handler_stack_memory.data();
   handler_stack.ss_size = kHandlerStackSize;
diff -uNr first/sh_linux-unwind.h second/sh_linux-unwind.h
--- first/sh_linux-unwind.h	2019-04-22 09:30:16.350797524 +0800
+++ second/sh_linux-unwind.h	2019-04-22 10:06:19.961172697 +0800
@@ -83,7 +83,7 @@
 	siginfo_t *pinfo;
 	void *puc;
 	siginfo_t info;
-	struct ucontext uc;
+	ucontext_t uc;
       } *rt_ = context->cfa;
       /* The void * cast is necessary to avoid an aliasing warning.
          The aliasing warning is correct, but should not be a problem
@@ -180,7 +180,7 @@
     {
       struct rt_sigframe {
 	siginfo_t info;
-	struct ucontext uc;
+	ucontext_t uc;
       } *rt_ = context->cfa;
       /* The void * cast is necessary to avoid an aliasing warning.
          The aliasing warning is correct, but should not be a problem
diff -uNr first/sh-signal.h second/sh-signal.h
--- first/sh-signal.h	2019-04-22 09:21:09.465644026 +0800
+++ second/sh-signal.h	2019-04-22 10:12:20.986678479 +0800
@@ -21,7 +21,7 @@
 
 /* The third parameter to the signal handler points to something with
  * this structure defined in asm/ucontext.h, but the name clashes with
- * struct ucontext from sys/ucontext.h so this private copy is used.  */
+ * ucontext_t from sys/ucontext.h so this private copy is used.  */
 typedef struct _sig_ucontext {
   unsigned long uc_flags;
   struct _sig_ucontext *uc_link;
diff -uNr first/tipepro_linux-unwind.h second/tipepro_linux-unwind.h
--- first/tipepro_linux-unwind.h	2019-04-22 09:31:16.882340290 +0800
+++ second/tipepro_linux-unwind.h	2019-04-22 10:06:54.968544440 +0800
@@ -61,7 +61,7 @@
   struct rt_sigframe {
     unsigned char save_area[C_ABI_SAVE_AREA_SIZE];
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
   } *rt_;
 
   /* Return if this is not a signal handler.  */
diff -uNr first/tsan_interceptors.cc second/tsan_interceptors.cc
--- first/tsan_interceptors.cc	2019-04-22 09:10:42.900211786 +0800
+++ second/tsan_interceptors.cc	2019-04-22 10:19:15.035204126 +0800
@@ -70,11 +70,6 @@
 struct ucontext_t {
   u64 opaque[768 / sizeof(u64) + 1];
 };
-#else
-struct ucontext_t {
-  // The size is determined by looking at sizeof of real ucontext_t on linux.
-  u64 opaque[936 / sizeof(u64) + 1];
-};
 #endif
 
 #if defined(__x86_64__) || defined(__mips__)
diff -uNr first/tsan_platform_linux.cc second/tsan_platform_linux.cc
--- first/tsan_platform_linux.cc	2019-04-22 13:29:19.350495088 +0800
+++ second/tsan_platform_linux.cc	2019-04-22 13:28:14.240862205 +0800
@@ -291,7 +291,7 @@
 int ExtractResolvFDs(void *state, int *fds, int nfd) {
 #if SANITIZER_LINUX
   int cnt = 0;
-  __res_state *statp = (__res_state*)state;
+  struct __res_state *statp = (struct __res_state*)state;
   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
     if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
       fds[cnt++] = statp->_u._ext.nssocks[i];
diff -uNr first/x86_64-signal.h second/x86_64-signal.h
--- first/x86_64-signal.h	2019-04-22 09:13:21.392748285 +0800
+++ second/x86_64-signal.h	2019-04-22 10:29:58.045474932 +0800
@@ -28,7 +28,7 @@
 #define HANDLE_DIVIDE_OVERFLOW						\
 do									\
 {									\
-  struct ucontext *_uc = (struct ucontext *)_p;				\
+  ucontext_t *_uc = (ucontext_t *)_p;				\
   gregset_t &_gregs = _uc->uc_mcontext.gregs;				\
   unsigned char *_rip = (unsigned char *)_gregs[REG_RIP];		\
 									\
diff -uNr first/xtensa_linux-unwind.h second/xtensa_linux-unwind.h
--- first/xtensa_linux-unwind.h	2019-04-22 09:32:00.485965348 +0800
+++ second/xtensa_linux-unwind.h	2019-04-22 10:07:26.371980541 +0800
@@ -67,7 +67,7 @@
 
   struct rt_sigframe {
     siginfo_t info;
-    struct ucontext uc;
+    ucontext_t uc;
   } *rt_;
 
   /* movi a2, __NR_rt_sigreturn; syscall */

2.3 安装补丁

patch -p0 < new_multi.patch

3 总结

(1) 查看不同版本文件比较信息:git diff path1 path2,其中path1为低版本文件所在路径,path2为高版本问文件所在路径;
(2) 创建补丁分为单文件补丁和多文件补丁,创建命令见下表: path表示文件所在路径,file表示文件名称如old.h,批量补丁创建时,文件路径(文件夹)中对应的文件名相同.

文件形式创建命令
单文件diff -uN old_path/file new_path/file > add.patch
多文件diff -uNr old_path new_path > add.patch

(3) 在补丁中查看文件版本差异信息:more add.patch;
(4) 安装补丁

文件形式安装命令
单文件patch -p0 < add.patch
多文件patch -p0 < multi_add.patch

(5) 解除补丁:

文件形式解除命令
单文件patch -RE -p0 < add.patch
多文件patch -R -p0 < multi_add.patch

(6) p0:从当前目录查找文件,p1忽略第一层目录,查找文件,如生成的前缀路径a/,b/可忽略;


[参考文献]
[1]https://gcc.gnu.org/bugzilla/attachment.cgi?id=41921
[2]https://wenku.baidu.com/view/03e962ab1a37f111f1855b92.html
[3]https://blog.csdn.net/u010900754/article/details/79602959
[4]http://patchwork.ozlabs.org/patch/817840/


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值