blob: 497ad75b7a45fca5c9b7e81c855a986e82dba85b [file] [log] [blame]
Gabe Black36b24092011-11-16 23:01:37 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2009 coresystems GmbH
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 or later of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18 */
19
20#ifdef __GNUC__
21
22/*
23 * GCC's libgcc handling is quite broken. While the libgcc functions
24 * are always regparm(0) the code that calls them uses whatever the
25 * compiler call specifies. Therefore we need a wrapper around those
26 * functions. See gcc bug PR41055 for more information.
27 */
28#define WRAP_LIBGCC_CALL(type, name) \
29 type __normal_##name(type a, type b) __attribute__((regparm(0))); \
30 type __wrap_##name(type a, type b); \
Simon Glassd8819f92013-06-11 11:14:52 -070031 type __attribute__((no_instrument_function)) \
32 __wrap_##name(type a, type b) \
33 { return __normal_##name(a, b); }
Gabe Black36b24092011-11-16 23:01:37 +000034
35WRAP_LIBGCC_CALL(long long, __divdi3)
36WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
37WRAP_LIBGCC_CALL(long long, __moddi3)
38WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)
39
40#endif