1 | /* $Id: chk_stubs.c 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * glibc stubs for the VirtualBox Guest Addition X11 Client.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /* If we want the binary to be usable with glibc 2.3, we have to prevent
|
---|
19 | VBoxClient from containing later symbols. This includes resolution of
|
---|
20 | symbols from supc++ and gcc_eh. */
|
---|
21 |
|
---|
22 | #include <stdio.h>
|
---|
23 | #include <stdarg.h>
|
---|
24 | #include <string.h>
|
---|
25 | #include <unistd.h>
|
---|
26 |
|
---|
27 | extern int __sprintf_chk(char *psz, int fFlags, size_t cb, const char *pszFormat, ...);
|
---|
28 | int __sprintf_chk(char *psz, int fFlags, size_t cb, const char *pszFormat, ...)
|
---|
29 | {
|
---|
30 | int rc;
|
---|
31 | va_list va;
|
---|
32 |
|
---|
33 | (void)fFlags;
|
---|
34 | va_start(va, pszFormat);
|
---|
35 | rc = vsnprintf(psz, cb, pszFormat, va);
|
---|
36 | va_end(va);
|
---|
37 | return rc;
|
---|
38 | }
|
---|
39 |
|
---|
40 | extern void __stack_chk_fail(void);
|
---|
41 | void __stack_chk_fail(void)
|
---|
42 | {
|
---|
43 | fprintf(stderr, "Stack check failed!\n");
|
---|
44 | _exit(1);
|
---|
45 | }
|
---|
46 |
|
---|
47 | #ifdef __x86_64
|
---|
48 | /* Furthermore, wrap references to memcpy to force them to go to the right
|
---|
49 | * version. We are forced to do it this way because the shared libraries
|
---|
50 | * supc++ and gcc_eh contain references which we cannot change. */
|
---|
51 |
|
---|
52 | extern void *__wrap_memcpy(void *dest, const void *src, size_t n);
|
---|
53 |
|
---|
54 | asm (".symver memcpy, memcpy@GLIBC_2.2.5");
|
---|
55 | void *__wrap_memcpy(void *dest, const void *src, size_t n)
|
---|
56 | {
|
---|
57 | return memcpy(dest, src, n);
|
---|
58 | }
|
---|
59 | #endif
|
---|