Guest User

Untitled

a guest
Mar 13th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 1.95 KB | None | 0 0
  1. #
  2. #       This program is free software; you can redistribute it and/or modify
  3. #       it under the terms of the GNU General Public License as published by
  4. #       the Free Software Foundation; either version 3 of the License, or
  5. #       (at your option) any later version.
  6. #
  7. #       Copyright (C) 2011 Luka Perkov <openwrt@lukaperkov.net>
  8. #
  9. #       Usage: mips-openwrt-linux-objdump -EB -b binary -m mips:isa32r2 -D YOUR_IMAGE_DUMP | awk -f lantiq_ram_extract_magic.awk
  10.  
  11. BEGIN {
  12.         print "/*                                                                            "
  13.         print " *       This program is free software; you can redistribute it and/or modify "
  14.         print " *       it under the terms of the GNU General Public License as published by "
  15.         print " *       the Free Software Foundation; either version 3 of the License, or    "
  16.         print " *       (at your option) any later version.                                  "
  17.         print " *                                                                            "
  18.         print " *       generated with lantiq_ram_extract_magic.awk                          "
  19.         print " */                                                                           "
  20.         print ""
  21.  
  22.         mc_dc_value=0
  23.         mc_dc_number=0
  24.         right_section=0
  25. }
  26.  
  27.  
  28. /t2,[0-9]+$/ {
  29.         if (right_section) {
  30.                 split($4, tmp, ",")
  31.                 mc_dc_value=sprintf("%X", tmp[2])
  32.         }
  33. }
  34.  
  35. /t2,[0-9]+\(t1\)$/ {
  36.         if (right_section) {
  37.                 split($4, tmp, ",")
  38.                 split(tmp[2], tmp, "(")
  39.                 mc_dc_number=tmp[1]/16
  40.         }
  41. }
  42.  
  43. {
  44.         if (right_section) {
  45.                 print "#define MC_DC" mc_dc_number "_VALUE\t0x" mc_dc_value
  46.  
  47.         }
  48.  
  49.         if ($4 == "t1,t1,0x1000")
  50.                 right_section=1
  51.  
  52.  
  53.         if ($4 == "t2,736(t1)")
  54.                 right_section=0
  55. }
  56.  
  57.  
  58. END {
  59.         print ""
  60. }
Add Comment
Please, Sign In to add comment