gcc.c 868 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * This file is part of the coreboot project.
  3. *
  4. * Copyright (C) 2009 coresystems GmbH
  5. *
  6. * SPDX-License-Identifier: GPL-2.0
  7. */
  8. #ifdef __GNUC__
  9. /*
  10. * GCC's libgcc handling is quite broken. While the libgcc functions
  11. * are always regparm(0) the code that calls them uses whatever the
  12. * compiler call specifies. Therefore we need a wrapper around those
  13. * functions. See gcc bug PR41055 for more information.
  14. */
  15. #define WRAP_LIBGCC_CALL(type, name) \
  16. type __normal_##name(type a, type b) __attribute__((regparm(0))); \
  17. type __wrap_##name(type a, type b); \
  18. type __attribute__((no_instrument_function)) \
  19. __wrap_##name(type a, type b) \
  20. { return __normal_##name(a, b); }
  21. WRAP_LIBGCC_CALL(long long, __divdi3)
  22. WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
  23. WRAP_LIBGCC_CALL(long long, __moddi3)
  24. WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)
  25. #endif