sysdep.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (C) 1993-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Brendan Kehoe (brendan@zen.org).
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #include <features.h>
  17. #if defined(PIC)
  18. /* Put this at the end of libc's text segment so that all of
  19. the direct branches from the syscalls are forward, and
  20. thus predicted not taken. */
  21. .section .text.last, "ax", @progbits
  22. #else
  23. .text
  24. #endif
  25. #if IS_IN (libc)
  26. # define SYSCALL_ERROR_ERRNO __libc_errno
  27. #else
  28. # define SYSCALL_ERROR_ERRNO errno
  29. #endif
  30. .align 4
  31. .globl __syscall_error
  32. .ent __syscall_error
  33. __syscall_error:
  34. /* When building a shared library, we branch here without having
  35. loaded the GP. Nor, since it was a direct branch, have we
  36. loaded PV with our address.
  37. When building a static library, we tail call here from another
  38. object file, possibly with a different GP, and must return with
  39. the GP of our caller in place so that linker relaxation works.
  40. Both issues are solved by computing the GP into T1 instead of
  41. clobbering the traditional GP register. */
  42. .prologue 0
  43. mov v0, t0
  44. br t1, 1f
  45. 1: ldah t1, 0(t1) !gpdisp!1
  46. call_pal PAL_rduniq
  47. lda t1, 0(t1) !gpdisp!1
  48. ldq t1, SYSCALL_ERROR_ERRNO(t1) !gottprel
  49. addq v0, t1, t1
  50. lda v0, -1
  51. stl t0, 0(t1)
  52. ret
  53. .end __syscall_error