Read about our upcoming Code of Conduct on this issue

Commit 475f8642 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

patchmgr: fix bad merge in reloc.c (52b733594b2e)

--HG--
branch : patchmgr
parent aaebab207561
......@@ -5,7 +5,7 @@
* the %pc relative addressing modes. These will be fixed-up to allow
* the function to be run from a new location.
*/
#ifndef __ARM__
#ifdef RELOC_PRINT
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
......@@ -16,7 +16,18 @@
#endif
#include "reloc.h"
#include "patch.h"
#include <patch.h>
#ifndef __ARM__
#define RELOC_PRINT
#endif
#ifdef CONFIG_QEMU
#include <qemu-util.h>
#define RELOC_PRINT
#define printf qprintf
#endif
int verbose = 1;
......@@ -48,7 +59,7 @@ reloc(
uint8_t * const mem = ((uint8_t*) buf) - load_addr;
// const uintptr_t func_len = func_end - func_offset;
#ifndef __ARM__
#ifdef RELOC_PRINT
printf( "Fixing from %08x to %08x\n", func_offset, func_end );
#endif
......@@ -82,7 +93,7 @@ reloc(
if( func_offset <= dest && dest < func_end )
continue;
#ifndef __ARM__
#ifdef RELOC_PRINT
if( verbose )
printf( "%08x: %08x B%s %08x => %08x\n",
pc,
......@@ -99,7 +110,7 @@ reloc(
if( new_jump >= +0x00800000
|| new_jump <= -0x00800000
) {
#ifndef __ARM__
#ifdef RELOC_PRINT
printf( "%08x: !!!! can not fixup jump from %08x to %08x (offset %s%08x)\n",
pc,
new_pc,
......@@ -115,7 +126,7 @@ reloc(
| (instr & ~BRANCH_OFFSET)
| (new_jump & BRANCH_OFFSET);
#ifndef __ARM__
#ifdef RELOC_PRINT
if(0)
printf( "%08x: %08x => %08x fixup offset %08x => %s%08x\n",
pc,
......@@ -158,7 +169,7 @@ reloc(
{
// Not an immediate 12-bit value;
// update the offset
#ifndef __ARM__
#ifdef RELOC_PRINT
printf( "%08x: unknown mode?\n", pc );
#endif
continue;
......@@ -173,8 +184,8 @@ reloc(
// Ignore offetss inside the reloc space
if( func_offset <= dest && dest < func_end )
continue;
#ifndef __ARM__
printf( "%08x: %08x add pc shift=%1x imm=%2x offset=%x => %08x\n",
#ifdef RELOC_PRINT
printf( "%08x: %08x add pc shift=%x imm=%2x offset=%x => %08x\n",
pc,
instr,
shift,
......@@ -190,7 +201,7 @@ reloc(
if( load == LOAD_INSTR )
{
uint32_t reg_base = (instr >> 16) & 0xF;
// uint32_t reg_dest = (instr >> 12) & 0xF;
uint32_t reg_dest = (instr >> 12) & 0xF;
int32_t offset = (instr >> 0) & 0xFFF;
if( reg_base != REG_PC )
......@@ -223,7 +234,7 @@ reloc(
| ( instr & ~0xFFF )
| ( new_offset & 0xFFF )
;
#ifndef __ARM__
#ifdef RELOC_PRINT
// This is one that will need to be copied
// but we currently don't do anything!
printf( "%08x: %08x LD %d, %d, %d => %08x: %08x %d data=%08x\n",
......@@ -237,7 +248,8 @@ reloc(
new_offset,
data
);
#else
#endif
#ifdef __ARM__
// Copy the data to the offset location
*(uint32_t*) fixups = data;
*(uint32_t*) new_pc = new_instr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment