Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ AC_SUBST(HOST_OS)
case "${host_cpu}" in
arm*|sa110) HOST_CPU="arm" ;;
cris*) HOST_CPU="cris" ;;
loongarch*) HOST_CPU="loongarch" ;;
mips*) HOST_CPU="mips" ;;
powerpc|powerpc64|powerpc64le) HOST_CPU="ppc" ;;
sun4u|sparc64) HOST_CPU="sparc" ;;
Expand Down Expand Up @@ -217,6 +218,7 @@ if test x"$enable_libunwind" = xyes; then
powerpc) UNWIND_ARCH="ppc32" ;;
powerpc64|powerpc64le) UNWIND_ARCH="ppc64" ;;
mips*) UNWIND_ARCH="mips" ;;
loongarch*) UNWIND_ARCH="loongarch" ;;
*) UNWIND_ARCH="${host_cpu}" ;;
esac

Expand Down Expand Up @@ -407,6 +409,7 @@ AC_CONFIG_FILES([
sysdeps/linux-gnu/arm/Makefile
sysdeps/linux-gnu/cris/Makefile
sysdeps/linux-gnu/ia64/Makefile
sysdeps/linux-gnu/loongarch/Makefile
sysdeps/linux-gnu/m68k/Makefile
sysdeps/linux-gnu/metag/Makefile
sysdeps/linux-gnu/mips/Makefile
Expand Down
25 changes: 25 additions & 0 deletions sysdeps/linux-gnu/loongarch/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is part of ltrace.
# Copyright (C) 2024 Loongson Technology Corporation Limited.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA

noinst_LTLIBRARIES = ../libcpu.la

___libcpu_la_SOURCES = fetch.c plt.c regs.c trace.c

noinst_HEADERS = arch.h ptrace.h signalent.h syscallent.h

MAINTAINERCLEANFILES = Makefile.in
48 changes: 48 additions & 0 deletions sysdeps/linux-gnu/loongarch/arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* This file is part of ltrace.
* Copyright (C) 2024 Loongson Technology Corporation Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

#ifndef LTRACE_LOONGARCH_ARCH_H
#define LTRACE_LOONGARCH_ARCH_H


/* | 31 15 | 14 0 |
* | 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 | code | */
#define BREAKPOINT_VALUE { 0x00, 0x00, 0x2A, 0x00 }
#define BREAKPOINT_LENGTH 4
#define DECR_PC_AFTER_BREAK 0
#define ARCH_ENDIAN_LITTLE

#define LT_ELFCLASS ELFCLASS64
#define LT_ELF_MACHINE EM_LOONGARCH

#define ARCH_HAVE_SIZEOF
#define ARCH_HAVE_ALIGNOF
#define ARCH_HAVE_ADD_PLT_ENTRY
#define ARCH_HAVE_SW_SINGLESTEP
#define ARCH_HAVE_FETCH_ARG
#define ARCH_HAVE_FETCH_PACK

#define RLEN 8
#define ARG_GAR_START 4
#define ARG_GAR_END 11
#define ARG_FAR_START 0
#define ARG_FAR_END 7

#endif /* LTRACE_LOONGARCH_ARCH_H */
Loading