Advertisement
Guest User

buildsdk.rb

a guest
Jul 9th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.76 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. memory_base = 0x08804000;
  4.  
  5. f = File.new("functions.txt", "r")
  6. h = {}
  7. #0x267A6DD2 [0x08A888E8] - __sceSasRevParam
  8. regexp = /^(0x.+) \[(0x.+)\] - (.+)$/
  9. while (line = f.gets)
  10.     if (line.match(regexp))
  11.       line.scan(regexp) {|nid,address,name|
  12.         h[name] = "0x" + (address.hex + memory_base).to_s(16).rjust(8, "0");
  13.       }
  14.     end
  15. end
  16.  
  17.  
  18. out = File.new("sdk.S", "w")
  19.  
  20. out.puts %Q{.macro AddNID funcname, nid
  21.  
  22.     .globl  \\funcname
  23.     .ent    \\funcname
  24. \\funcname = \\nid
  25.     .end    \\funcname
  26.  
  27. .endm
  28.  
  29.     .file   1 "sdk.c"
  30.     .section .mdebug.eabi32
  31.     .section .gcc_compiled_long32
  32.     .previous
  33.     .text
  34.     .align  2
  35.    
  36.    
  37. }
  38.  
  39. h.each { |function,address|
  40.     out.puts "\tAddNID #{function}, #{address}"
  41. }
  42.  
  43. out.puts %Q{
  44.  
  45.  
  46.     .ident  "VAL-SDK"
  47. }
  48. out.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement