This script is tested with ruby 1.8.7 and awk 4.0.0. Earlier/later versions may or may not work. Two important lessons about using this:
(1) Don't use it while in an X session running fglrx! You can use it if you're running vesa or the open source radeon driver, but if you're trying to patch the same version of fglrx that you're currently running in your session, your system will probably hang when you use this. The easiest way to fix this while still retaining an Xorg session is to edit xorg.conf to replace Driver "fglrx" with Driver "vesa". If you don't want to do that, just run "init 1" as root and you'll probably be dropped to a VT and Xorg will be killed (this is what we want).
(2) Don't use it if you don't get any watermark in your driver! This is only for getting rid of watermark in pre-release beta drivers, for example the recent build of 8.96 published for OpenCL 1.2 support (so you can actually enjoy using them), or getting rid of "Unsupported Hardware" bug in production drivers (because technically if you are able to start fglrx at all with your hardware, it shouldn't be displaying that; but sometimes very new hardware will encounter this bug).
Save this code as a script, make it executable and run it as root:
chmod +x lolsed.rb
./lolsed.rb
#append sudo to the previous command if you run Ubuntu/Debian and aren't in a # root shell
SPECIAL THANKS: Kano (for the original concept / binary hacking). I edited his script to make it work with recent fglrx by re-writing it in Ruby instead of bash (there were some escaping issues with his bash script).
(1) Don't use it while in an X session running fglrx! You can use it if you're running vesa or the open source radeon driver, but if you're trying to patch the same version of fglrx that you're currently running in your session, your system will probably hang when you use this. The easiest way to fix this while still retaining an Xorg session is to edit xorg.conf to replace Driver "fglrx" with Driver "vesa". If you don't want to do that, just run "init 1" as root and you'll probably be dropped to a VT and Xorg will be killed (this is what we want).
(2) Don't use it if you don't get any watermark in your driver! This is only for getting rid of watermark in pre-release beta drivers, for example the recent build of 8.96 published for OpenCL 1.2 support (so you can actually enjoy using them), or getting rid of "Unsupported Hardware" bug in production drivers (because technically if you are able to start fglrx at all with your hardware, it shouldn't be displaying that; but sometimes very new hardware will encounter this bug).
Save this code as a script, make it executable and run it as root:
chmod +x lolsed.rb
./lolsed.rb
#append sudo to the previous command if you run Ubuntu/Debian and aren't in a # root shell
Code:
#!/usr/bin/env ruby if !File.exists?(`which objdump`.chomp!) || !File.exists?(`which awk`.chomp!) puts "Can't find objdump; please check your installation." Process.exit!(false) end if ARGV[0].nil? || !File.exists?(ARGV[0]) fglrx = "/usr/lib64/xorg/modules/drivers/fglrx_drv.so" if !File.exists?(fglrx) fglrx = "/usr/lib/xorg/modules/drivers/fglrx_drv.so" if !File.exists?(fglrx) puts "Can't find fglrx_drv.so; try to specify it as a command-line argument" Process.exit!(false) end end else fglrx = ARGV[0] end fglrx_str = IO.read(fglrx) puts "Read #{fglrx}: #{fglrx_str.bytesize}" if fglrx_str.bytesize < 1000 puts "Can't read from #{fglrx} or file is very small; something is wrong!" Process.exit!(false) end dump = `objdump -d "#{fglrx}"` puts "objdump returned #{dump.bytesize} bytes" if dump.bytesize < 1 puts "objdump failed on #{fglrx}; something is wrong!" Process.exit!(false) end awkcmd = %q!/callq/&&/atiddxEnableLogo/{print "\\\\x"$2"\\\\x"$3"\\\\x"$4"\\\\x"$5"\\\\x"$6}! proc = IO.popen(%Q!awk '#{awkcmd}'!, mode="w+") proc.write(dump) proc.close_write awkresult = proc.read if awkresult.bytesize < 1 puts "awk failed on #{fglrx}; either something is wrong, or you have no EnableLogo calls left to substitute out!" Process.exit!(false) end puts "awk result: #{awkresult}" results = awkresult.split("\n") puts "Results: #{results.count} items" results.each { |result| puts "Looking for #{result}" fglrx_str.gsub!(/#{result}/, "\x90\x90\x90\x90\x90") } ofile = File.open(fglrx, "w") written = ofile.write(fglrx_str) ofile.flush ofile.fsync ofile.close puts "#{written} bytes written to #{fglrx}" Process.exit(true)
Comment