diff --git a/model/dce-stdio.cc b/model/dce-stdio.cc index 076dffcf..6b1ecbe2 100644 --- a/model/dce-stdio.cc +++ b/model/dce-stdio.cc @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include NS_LOG_COMPONENT_DEFINE ("DceStdio"); @@ -726,7 +726,7 @@ int dce___printf_chk (int __flag, __const char *__restrict __format, ...) } int dce___vfprintf_chk (FILE *__restrict __stream, int __flag, - __const char *__restrict __format, _G_va_list __ap) + __const char *__restrict __format, __gnuc_va_list __ap) { NS_LOG_FUNCTION (Current () << UtilsGetNodeId ()); NS_ASSERT (Current () != 0); @@ -761,7 +761,7 @@ int dce___snprintf_chk (char *__restrict __s, size_t __n, int __flag, } int dce___vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, size_t __slen, - __const char *__restrict __format, _G_va_list __ap) + __const char *__restrict __format, __gnuc_va_list __ap) { NS_LOG_FUNCTION (Current () << UtilsGetNodeId ()); NS_ASSERT (Current () != 0); diff --git a/model/dce-stdio.h b/model/dce-stdio.h index 458442b1..2ce28922 100644 --- a/model/dce-stdio.h +++ b/model/dce-stdio.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -59,7 +60,7 @@ void dce_perror (const char *s); int dce___printf_chk (int __flag, __const char *__restrict __format, ...); int dce___vfprintf_chk (FILE *__restrict __stream, int __flag, - __const char *__restrict __format, _G_va_list __ap); + __const char *__restrict __format, __gnuc_va_list __ap); int dce___fprintf_chk (FILE *__restrict __stream, int __flag, __const char *__restrict __format, ...); int dce___snprintf_chk (char *__restrict __s, size_t __n, int __flag, @@ -73,7 +74,7 @@ int dce_vasprintf (char **strp, const char *fmt, va_list ap); int dce_vsnprintf (char *s, size_t si, const char *f, va_list ap); int dce___vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, size_t __slen, - __const char *__restrict __format, _G_va_list __ap); + __const char *__restrict __format, __gnuc_va_list __ap); #ifdef __cplusplus diff --git a/model/libc-dce.cc b/model/libc-dce.cc index f130ec57..2c0528b2 100644 --- a/model/libc-dce.cc +++ b/model/libc-dce.cc @@ -108,6 +108,7 @@ #include #include #include +#include extern void __cxa_finalize (void *d); extern int __cxa_atexit (void (*func)(void *), void *arg, void *d); @@ -135,24 +136,26 @@ extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW; extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...) __THROW; extern int __vsprintf_chk (char *, int, size_t, const char *, - _G_va_list) __THROW; + __gnuc_va_list) __THROW; extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *, - _G_va_list) __THROW; + __gnuc_va_list) __THROW; extern int __printf_chk (int, const char *, ...); extern int __fprintf_chk (FILE *, int, const char *, ...); -extern int __vprintf_chk (int, const char *, _G_va_list); -extern int __vfprintf_chk (FILE *, int, const char *, _G_va_list); +extern int __vprintf_chk (int, const char *, __gnuc_va_list); +extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list); extern char * __fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp); extern char * __fgets_chk (char *buf, size_t size, int n, FILE *fp); extern int __asprintf_chk (char **, int, const char *, ...) __THROW; -extern int __vasprintf_chk (char **, int, const char *, _G_va_list) __THROW; +extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW; extern int __dprintf_chk (int, int, const char *, ...); -extern int __vdprintf_chk (int, int, const char *, _G_va_list); +extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list); extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) __THROW; extern int __obstack_vprintf_chk (struct obstack *, int, const char *, - _G_va_list) __THROW; + __gnuc_va_list) __THROW; extern void __stack_chk_fail (void); +extern int _IO_getc(_IO_FILE * __fp); +extern int _IO_putc(int __c, _IO_FILE * __fp); typedef void (*func_t)(...); diff --git a/test/test-socket.cc b/test/test-socket.cc index 506fda52..fb8a9a53 100644 --- a/test/test-socket.cc +++ b/test/test-socket.cc @@ -12,6 +12,7 @@ #include #include #include "test-macros.h" +#include #undef OUTPUT #define OUTPUT(s) (std::cout << s << std::endl) diff --git a/utils/glibc-2.31-disable-security-checks.patch b/utils/glibc-2.31-disable-security-checks.patch new file mode 100644 index 00000000..6bef68f6 --- /dev/null +++ b/utils/glibc-2.31-disable-security-checks.patch @@ -0,0 +1,28 @@ +diff --git a/elf/dl-load.c b/elf/dl-load.c +index a6b80f9395..e7dca92238 100644 +--- a/elf/dl-load.c ++++ b/elf/dl-load.c +@@ -1205,9 +1205,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, + /* Make sure we are not dlopen'ing an object that has the + DF_1_NOOPEN flag set, or a PIE object. */ + if ((__glibc_unlikely (l->l_flags_1 & DF_1_NOOPEN) +- && (mode & __RTLD_DLOPEN)) +- || (__glibc_unlikely (l->l_flags_1 & DF_1_PIE) +- && __glibc_unlikely ((mode & __RTLD_OPENEXEC) == 0))) ++ && (mode & __RTLD_DLOPEN))) + { + /* We are not supposed to load this object. Free all resources. */ + _dl_unmap_segments (l); +diff --git a/libio/vtables.c b/libio/vtables.c +index 17f2e8e587..73e6906768 100644 +--- a/libio/vtables.c ++++ b/libio/vtables.c +@@ -69,7 +69,7 @@ _IO_vtable_check (void) + return; + #endif + +- __libc_fatal ("Fatal error: glibc detected an invalid stdio handle\n"); ++ //__libc_fatal ("Fatal error: glibc detected an invalid stdio handle\n"); + } + + /* Some variants of libstdc++ interpose _IO_2_1_stdin_ etc. and diff --git a/utils/linker-script-py-to-py3.patch b/utils/linker-script-py-to-py3.patch new file mode 100644 index 00000000..36a30ded --- /dev/null +++ b/utils/linker-script-py-to-py3.patch @@ -0,0 +1,10 @@ +diff --git a/arch/lib/generate-linker-script.py b/arch/lib/generate-linker-script.py +index db3d7f8dab16..93971ee4871d 100755 +--- a/arch/lib/generate-linker-script.py ++++ b/arch/lib/generate-linker-script.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + + import re + diff --git a/wscript b/wscript index 61cc95ec..4710389d 100755 --- a/wscript +++ b/wscript @@ -35,6 +35,10 @@ def options(opt): help=('Specify the installed directory of elf-loader'), dest='with_elf_loader', type='string', default=None) + opt.add_option('--with-glibc', + help=('Specify the installed directory of Glibc-2.25'), + dest='with_glibc', type='string', + default=None) opt.add_option('--with-libaspect', help=('Specify the installed directory of libaspect.so'), dest='with_libaspect', type='string', @@ -87,6 +91,13 @@ def _check_nonfatal(conf, *args, **kwargs): def configure(conf): + conf.env.GLIBC_INSTALL_DIR = os.path.abspath(conf.options.with_glibc) + + if not os.path.exists(conf.env.GLIBC_INSTALL_DIR): + Logs.error("Custom glibc install directory does not exist ! Please pass a valid directory in --with-glibc argument") + raise SystemExit(1) + return + conf.load('relocation', tooldir=['waf-tools']) conf.load('compiler_c') cc_string = '.'.join(conf.env['CC_VERSION']) @@ -99,6 +110,7 @@ def configure(conf): conf.load('clang_compilation_database', tooldir=['waf-tools']) conf.load('command', tooldir=['waf-tools']) + if Options.options.with_ns3 is not None and os.path.isdir(Options.options.with_ns3): conf.env['NS3_DIR']= os.path.abspath(Options.options.with_ns3) if not 'PKG_CONFIG_PATH' in os.environ: @@ -759,6 +771,21 @@ def build(bld): 'helper/freebsd-stack-helper.h', ] + SYSROOT = bld.env.GLIBC_INSTALL_DIR + extra_cflags_root = [ + '-L'+SYSROOT+'/usr/lib64', + '-I'+SYSROOT+'/include', + '--sysroot='+SYSROOT, + '-Wl,--start-group', + '-Wl,-rpath='+SYSROOT+'/lib64', + '-Wl,-rpath-link=/usr/lib/x86_64-linux-gnu', + '-Wl,--dynamic-linker='+SYSROOT+'/lib64/ld-2.31.so' + ] + wl_end_group = [ + '-Wl,--end-group' + ] + + bld.env.append_value('LINKFLAGS',extra_cflags_root+wl_end_group) module_source = module_source + kernel_source module_headers = module_headers + kernel_headers uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet', 'netlink']) @@ -767,7 +794,7 @@ def build(bld): headers=module_headers, use=uselib, includes=kernel_includes, - cxxflags= ['-Wno-deprecated-declarations'], + cxxflags= extra_cflags_root+['-Wno-deprecated-declarations']+wl_end_group, lib=['dl']) # lib=['dl','efence']) @@ -820,7 +847,7 @@ def build(bld): # and forward to the dce_* code bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc', 'model/libc-global-variables.cc'], target='lib/c-ns3', - cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'], + cxxflags=extra_cflags_root+['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch']+wl_end_group, defines=['LIBSETUP=libc_setup'], linkflags=['-nostdlib', '-fno-profile-arcs', '-Wl,--version-script=' + os.path.join('model', 'libc.version'), @@ -829,7 +856,7 @@ def build(bld): # and forward to the dce_* code bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'], target='lib/pthread-ns3', - cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'], + cxxflags=extra_cflags_root+['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch']+wl_end_group, defines=['LIBSETUP=libpthread_setup'], linkflags=['-nostdlib', '-fno-profile-arcs', '-Wl,--version-script=' + os.path.join('model', 'libpthread.version'), @@ -839,7 +866,7 @@ def build(bld): # and forward to the dce_* code bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'], target='lib/rt-ns3', - cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'], + cxxflags=extra_cflags_root+['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch']+wl_end_group, defines=['LIBSETUP=librt_setup'], linkflags=['-nostdlib', '-fno-profile-arcs', '-Wl,--version-script=' + os.path.join('model', 'librt.version'), @@ -849,7 +876,7 @@ def build(bld): # and forward to the dce_* code bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'], target='lib/m-ns3', - cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'], + cxxflags=extra_cflags_root+['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch']+wl_end_group, defines=['LIBSETUP=libm_setup'], linkflags=['-nostdlib', '-fno-profile-arcs', '-Wl,--version-script=' + os.path.join('model', 'libm.version'), @@ -859,7 +886,7 @@ def build(bld): # and forward to the dce_* code bld.shlib(source = ['model/libc.cc', 'model/libc-setup.cc'], target='lib/dl-ns3', - cxxflags=['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch'], + cxxflags=extra_cflags_root+['-g', '-fno-profile-arcs', '-fno-test-coverage', '-Wno-builtin-declaration-mismatch']+wl_end_group, defines=['LIBSETUP=libdl_setup'], linkflags=['-nostdlib', '-fno-profile-arcs', '-Wl,--version-script=' + os.path.join('model', 'libdl.version'),