Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd29defe authored by Christopher Ferris's avatar Christopher Ferris Committed by android-build-merger
Browse files

Merge "Add libunwindstack support for Mips and Mips64" am: 515bff81

am: de3d7412

Change-Id: I22774753f296cda5c4bb484b22e72caea82a94ff
parents 7cb4316c de3d7412
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ cc_library {
        "RegsArm64.cpp",
        "RegsX86.cpp",
        "RegsX86_64.cpp",
        "RegsMips.cpp",
        "RegsMips64.cpp",
        "Unwinder.cpp",
        "Symbols.cpp",
    ],
@@ -86,6 +88,12 @@ cc_library {
        x86_64: {
            srcs: ["AsmGetRegsX86_64.S"],
        },
        mips: {
            srcs: ["AsmGetRegsMips.S"],
        },
        mips64: {
            srcs: ["AsmGetRegsMips64.S"],
        },
    },

    shared_libs: [
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

  .text
  .type     AsmGetRegs, %function
  .globl    AsmGetRegs
  .ent      AsmGetRegs
  .balign   16
AsmGetRegs:
  .cfi_startproc
  .cfi_def_cfa $sp, 0
  .set push
  .set noreorder
  .cpload $t9
  sw   $zero, 0($a0)
  .set noat
  sw   $at, 4($a0)
  .set at
  sw   $v0, 8($a0)
  sw   $v1, 12($a0)
  sw   $a0, 16($a0)
  sw   $a1, 20($a0)
  sw   $a2, 24($a0)
  sw   $a3, 28($a0)
  sw   $t0, 32($a0)
  sw   $t1, 36($a0)
  sw   $t2, 40($a0)
  sw   $t3, 44($a0)
  sw   $t4, 48($a0)
  sw   $t5, 52($a0)
  sw   $t6, 56($a0)
  sw   $t7, 60($a0)
  sw   $s0, 64($a0)
  sw   $s1, 68($a0)
  sw   $s2, 72($a0)
  sw   $s3, 76($a0)
  sw   $s4, 80($a0)
  sw   $s5, 84($a0)
  sw   $s6, 88($a0)
  sw   $s7, 92($a0)
  sw   $t8, 96($a0)
  sw   $t9, 100($a0)
  sw   $k0, 104($a0)
  sw   $k1, 108($a0)
  sw   $gp, 112($a0)
  sw   $sp, 116($a0)
  sw   $s8, 120($a0)
  sw   $ra, 124($a0)
  jalr $zero, $ra
  sw   $ra, 128($a0)   // set PC to the calling function

  .set pop
  .cfi_endproc
  .size     AsmGetRegs, .-AsmGetRegs
  .end      AsmGetRegs
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

  .text
  .type     AsmGetRegs, %function
  .globl    AsmGetRegs
  .ent      AsmGetRegs
  .balign    16
AsmGetRegs:
  .cfi_startproc
  .cfi_def_cfa $sp, 0
  .set push
  .set noreorder
  .cpload $t9
  sd   $zero, 0($a0)
  .set noat
  sd   $at, 8($a0)
  .set at
  sd   $v0, 16($a0)
  sd   $v1, 24($a0)
  sd   $a0, 32($a0)
  sd   $a1, 40($a0)
  sd   $a2, 48($a0)
  sd   $a3, 56($a0)
  sd   $a4, 64($a0)
  sd   $a5, 72($a0)
  sd   $a6, 80($a0)
  sd   $a7, 88($a0)
  sd   $t0, 96($a0)
  sd   $t1, 104($a0)
  sd   $t2, 112($a0)
  sd   $t3, 120($a0)
  sd   $s0, 128($a0)
  sd   $s1, 136($a0)
  sd   $s2, 144($a0)
  sd   $s3, 152($a0)
  sd   $s4, 160($a0)
  sd   $s5, 168($a0)
  sd   $s6, 176($a0)
  sd   $s7, 184($a0)
  sd   $t8, 192($a0)
  sd   $t9, 200($a0)
  sd   $k0, 208($a0)
  sd   $k1, 216($a0)
  sd   $gp, 224($a0)
  sd   $sp, 232($a0)
  sd   $s8, 240($a0)
  sd   $ra, 248($a0)
  jalr $zero, $ra
  sd   $ra, 256($a0)   // set PC to the calling function

  .set pop
  .cfi_endproc
  .size AsmGetRegs, .-AsmGetRegs
  .end      AsmGetRegs
+8 −2
Original line number Diff line number Diff line
@@ -189,9 +189,12 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) {
    } else if (e_machine == EM_386) {
      arch_ = ARCH_X86;
      interface.reset(new ElfInterface32(memory));
    } else if (e_machine == EM_MIPS) {
      arch_ = ARCH_MIPS;
      interface.reset(new ElfInterface32(memory));
    } else {
      // Unsupported.
      ALOGI("32 bit elf that is neither arm nor x86: e_machine = %d\n", e_machine);
      ALOGI("32 bit elf that is neither arm nor x86 nor mips: e_machine = %d\n", e_machine);
      return nullptr;
    }
  } else if (class_type_ == ELFCLASS64) {
@@ -205,9 +208,12 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) {
      arch_ = ARCH_ARM64;
    } else if (e_machine == EM_X86_64) {
      arch_ = ARCH_X86_64;
    } else if (e_machine == EM_MIPS) {
      arch_ = ARCH_MIPS64;
    } else {
      // Unsupported.
      ALOGI("64 bit elf that is neither aarch64 nor x86_64: e_machine = %d\n", e_machine);
      ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n",
            e_machine);
      return nullptr;
    }
    interface.reset(new ElfInterface64(memory));
+66 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _LIBUNWINDSTACK_MACHINE_MIPS_H
#define _LIBUNWINDSTACK_MACHINE_MIPS_H

#include <stdint.h>

namespace unwindstack {

enum MipsReg : uint16_t {
  MIPS_REG_R0 = 0,
  MIPS_REG_R1,
  MIPS_REG_R2,
  MIPS_REG_R3,
  MIPS_REG_R4,
  MIPS_REG_R5,
  MIPS_REG_R6,
  MIPS_REG_R7,
  MIPS_REG_R8,
  MIPS_REG_R9,
  MIPS_REG_R10,
  MIPS_REG_R11,
  MIPS_REG_R12,
  MIPS_REG_R13,
  MIPS_REG_R14,
  MIPS_REG_R15,
  MIPS_REG_R16,
  MIPS_REG_R17,
  MIPS_REG_R18,
  MIPS_REG_R19,
  MIPS_REG_R20,
  MIPS_REG_R21,
  MIPS_REG_R22,
  MIPS_REG_R23,
  MIPS_REG_R24,
  MIPS_REG_R25,
  MIPS_REG_R26,
  MIPS_REG_R27,
  MIPS_REG_R28,
  MIPS_REG_R29,
  MIPS_REG_R30,
  MIPS_REG_R31,
  MIPS_REG_PC,
  MIPS_REG_LAST,

  MIPS_REG_SP = MIPS_REG_R29,
  MIPS_REG_RA = MIPS_REG_R31,
};

}  // namespace unwindstack

#endif  // _LIBUNWINDSTACK_MACHINE_MIPS_H
 No newline at end of file
Loading