index.xml (54212B)
1 <?xml version="1.0" encoding="utf-8" standalone="yes"?> 2 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 3 <channel> 4 <title>Software on Chris Bracken</title> 5 <link>https://chris.bracken.jp/tags/software/</link> 6 <description>Recent content in Software on Chris Bracken</description> 7 <generator>Hugo -- gohugo.io</generator> 8 <language>en</language> 9 <managingEditor>chris@bracken.jp (Chris Bracken)</managingEditor> 10 <webMaster>chris@bracken.jp (Chris Bracken)</webMaster> 11 <lastBuildDate>Wed, 31 Oct 2018 00:00:00 +0000</lastBuildDate><atom:link href="https://chris.bracken.jp/tags/software/index.xml" rel="self" type="application/rss+xml" /> 12 <item> 13 <title>Hand-decoding an ELF binary image</title> 14 <link>https://chris.bracken.jp/2018/10/decoding-an-elf-binary/</link> 15 <pubDate>Wed, 31 Oct 2018 00:00:00 +0000</pubDate> 16 <author>chris@bracken.jp (Chris Bracken)</author> 17 <guid>https://chris.bracken.jp/2018/10/decoding-an-elf-binary/</guid> 18 <description><p>While recovering from some dentistry the other day I figured I&rsquo;d have a go at 19 better understanding the ELF binary format. What better way to do that than to 20 compile a small program and hand-decode the resulting binary with a hex editor 21 and whatever ELF format spec I could find.</p> 22 <h2 id="overview">Overview</h2> 23 <p>Below, we&rsquo;ll use <code>nasm</code> to build a small assembly Hello World program to a 24 64-bit ELF object file, then link that into an ELF executable with GNU <code>ld</code>. 25 Finally, we&rsquo;ll run the resulting object file and binary image through <code>xxd</code> and 26 hand-decode the resulting hex.</p> 27 <p>The code and instructions below work on FreeBSD 11 on x86_64 hardware. For 28 other operating systems, hardware, and toolchains, you&rsquo;re on your own! I&rsquo;d 29 imagine this should all work just fine on Linux. If I get bored one day, I may 30 redo this for Mach-O binaries on macOS.</p> 31 <h2 id="helloasm">hello.asm</h2> 32 <p>First we&rsquo;ll bang up a minimal Hello World program in assembly. In the <code>.data</code> 33 section, we add a null-terminated string, <code>hello</code>, and its length <code>hbytes</code>. In 34 the program text, we set up and execute the <code>write(stdout, hello, hbytes)</code> 35 syscall, then set up and execute an <code>exit(0)</code> syscall.</p> 36 <p>Note that 64-bit FreeBSD, macOS, and Linux all use the SysV AMD64 calling 37 convention. For calls against the kernel interface, the syscall number is 38 stored in <code>rax</code> and up to six parameters are passed, in order, in <code>rdi</code>, <code>rsi</code>, 39 <code>rdx</code>, <code>r10</code>, <code>r8</code>, <code>r9</code>. For user calls, replace <code>r10</code> with <code>rcx</code> in this 40 list, and pass further arguments on the stack. In all cases, the return value 41 is passed through <code>rax</code>. More details can be found in section A.2.1 of the 42 <a href="https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf">System V AMD64 ABI Reference</a>.</p> 43 <pre><code>; hello.asm 44 45 %define stdin 0 46 %define stdout 1 47 %define stderr 2 48 %define SYS_exit 1 49 %define SYS_write 4 50 51 %macro system 1 52 mov rax, %1 53 syscall 54 %endmacro 55 56 %macro sys.exit 0 57 system SYS_exit 58 %endmacro 59 60 %macro sys.write 0 61 system SYS_write 62 %endmacro 63 64 section .data 65 hello db 'Hello, World!', 0Ah 66 hbytes equ $-hello 67 68 section .text 69 global _start 70 _start: 71 mov rdi, stdout 72 mov rsi, hello 73 mov rdx, hbytes 74 sys.write 75 76 xor rdi,rdi 77 sys.exit 78 </code></pre> 79 <h2 id="compile-to-object-code">Compile to object code</h2> 80 <p>Next, we&rsquo;ll compile <code>hello.asm</code> to a 64-bit ELF object file using <code>nasm</code>:</p> 81 <pre><code>% nasm -f elf64 hello.asm 82 </code></pre> 83 <p>This emits <code>hello.o</code>, an 880-byte ELF-64 object file. Since we haven&rsquo;t yet run 84 this through the linker, addresses of global symbols (in this case, <code>hello</code>) 85 are not yet known and thus left with address 0x0 placeholders. We can see this 86 in the <code>movabs</code> instruction at offset 0x15 of the <code>.text</code> section below.</p> 87 <p>The relocation section (Section 6: <code>.rela.text</code>) contains an entry for each 88 symbolic reference that needs to be filled in by the linker. In this case 89 there&rsquo;s just a single entry for the symbol <code>hello</code> (which points to our hello 90 world string). The relocation table entry&rsquo;s <code>r_offset</code> indicates the address to 91 replace is at an offset of 0x7 into the section of the associated symbol table 92 entry. Its <code>r_info</code> (0x0000000200000001) encodes a relocation type in its lower 93 4 bytes (0x1: <code>R_AMD64_64</code>) and the associated symbol table entry in its upper 94 4 bytes (0x2, which, if we look it up in the symbol table is the <code>.text</code> 95 section). The <code>r_addend</code> field (0x0) specifies an additional adjustment to the 96 substituted symbol to be applied at link time; specifically, for the 97 <code>R_AMD64_64</code>, the final address is computed as S + A, where S is the 98 substituted symbol value (in our case, the address of <code>hello</code>) and A is the 99 addend (in our case, 0x0).</p> 100 <p>Without further ado, let&rsquo;s dump the object file:</p> 101 <pre><code>% xxd hello.o 102 </code></pre> 103 <p>With whatever ELF64 <a href="https://docs.oracle.com/cd/E19120-01/open.solaris/819-0690/index.html">linker &amp; loader guide</a> we can find at hand, 104 let&rsquo;s get decoding this thing:</p> 105 <h3 id="elf-header">ELF Header</h3> 106 <pre><code>|00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000| .ELF............ 107 |00000010: 0100 3e00 0100 0000 0000 0000 0000 0000| ..&gt;............. 108 |00000020: 0000 0000 0000 0000 4000 0000 0000 0000| ........@....... 109 |00000030: 0000 0000 4000 0000 0000 4000 0700 0300| ....@.....@..... 110 111 e_ident[EI_MAG0..EI_MAG3] 0x7f + ELF Magic 112 e_ident[EI_CLASS] 0x02 64-bit 113 e_ident[EI_DATA] 0x01 Little-endian 114 e_ident[EI_VERSION] 0x01 ELF v1 115 e_ident[EI_OSABI] 0x00 System V 116 e_ident[EI_ABIVERSION] 0x00 Unused 117 e_ident[EI_PAD] 0x00000000000000 7 bytes unused padding 118 e_type 0x0001 ET_REL 119 e_machine 0x003e x86_64 120 e_version 0x00000001 Version 1 121 e_entry 0x0000000000000000 Entrypoint address (none) 122 e_phoff 0x0000000000000000 Program header table offset in image 123 e_shoff 0x0000000000000040 Section header table offset in image 124 e_flags 0x00000000 Architecture-dependent interpretation 125 e_ehsize 0x0040 Size of this ELF header (64B) 126 e_phentsize 0x0000 Size of program header table entry 127 e_phnum 0x0000 Number of program header table entries 128 e_shentsize 0x0040 Size of section header table entry (64B) 129 e_shnum 0x0007 Number of section header table entries 130 e_shstrndx 0x0003 Index of section header for .shstrtab 131 </code></pre> 132 <h3 id="section-header-table-entry-0-null">Section header table: Entry 0 (null)</h3> 133 <pre><code>|00000040: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 134 |00000050: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 135 |00000060: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 136 |00000070: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 137 138 sh_name 0x00000000 Offset into .shstrtab 139 sh_type 0x00000000 SHT_NULL 140 sh_flags 0x0000000000000000 Section attributes 141 sh_addr 0x0000000000000000 Virtual address of section in memory 142 sh_offset 0x0000000000000000 Offset of section in file image 143 sh_size 0x0000000000000000 Size in bytes of section in file image 144 sh_link 0x00000000 Section index of associated section 145 sh_info 0x00000000 Extra info about section 146 sh_addralign 0x0000000000000000 Alignment 147 sh_entsize 0x0000000000000000 Size in bytes of each entry 148 </code></pre> 149 <h3 id="section-header-table-entry-1-data">Section header table: Entry 1 (.data)</h3> 150 <pre><code>|00000080: 0100 0000 0100 0000 0300 0000 0000 0000| ................ 151 |00000090: 0000 0000 0000 0000 0002 0000 0000 0000| ................ 152 |000000a0: 0e00 0000 0000 0000 0000 0000 0000 0000| ................ 153 |000000b0: 0400 0000 0000 0000 0000 0000 0000 0000| ................ 154 155 sh_name 0x00000001 Offset into .shstrtab 156 sh_type 0x00000001 SHT_PROGBITS 157 sh_flags 0x0000000000000003 SHF_WRITE | SHF_ALLOC 158 sh_addr 0x0000000000000000 Virtual address of section in memory 159 sh_offset 0x0000000000000200 Offset of section in file image 160 sh_size 0x000000000000000e Size in bytes of section in file image 161 sh_link 0x00000000 Section index of associated section 162 sh_info 0x00000000 Extra info about section 163 sh_addralign 0x0000000000000004 Alignment 164 sh_entsize 0x0000000000000000 Size in bytes of each entry 165 </code></pre> 166 <h3 id="section-header-table-entry-2-text">Section header table: Entry 2 (.text)</h3> 167 <pre><code>|000000c0: 0700 0000 0100 0000 0600 0000 0000 0000| ................ 168 |000000d0: 0000 0000 0000 0000 1002 0000 0000 0000| ................ 169 |000000e0: 2500 0000 0000 0000 0000 0000 0000 0000| %............... 170 |000000f0: 1000 0000 0000 0000 0000 0000 0000 0000| ................ 171 172 sh_name 0x00000007 Offset into .shstrtab 173 sh_type 0x00000001 SHT_PROGBITS 174 sh_flags 0x0000000000000006 SHF_ALLOC | SHF_EXECINSTR 175 sh_addr 0x0000000000000000 Virtual address of section in memory 176 sh_offset 0x0000000000000210 Offset of section in file image 177 sh_size 0x0000000000000025 Size in bytes of section in file image 178 sh_link 0x00000000 Section index of associated section 179 sh_info 0x00000000 Extra info about section 180 sh_addralign 0x0000000000000001 Alignment 181 sh_entsize 0x0000000000000000 Size in bytes of each entry 182 </code></pre> 183 <h3 id="section-header-table-entry-3-shstrtab">Section header table: Entry 3 (.shstrtab)</h3> 184 <pre><code>|00000100: 0d00 0000 0300 0000 0000 0000 0000 0000| ................ 185 |00000110: 0000 0000 0000 0000 4002 0000 0000 0000| ........@....... 186 |00000120: 3200 0000 0000 0000 0000 0000 0000 0000| 2............... 187 |00000130: 0100 0000 0000 0000 0000 0000 0000 0000| ................ 188 189 sh_name 0x0000000d Offset into .shstrtab 190 sh_type 0x00000003 SHT_STRTAB 191 sh_flags 0x0000000000000000 Section attributes 192 sh_addr 0x0000000000000000 Virtual address of section in memory 193 sh_offset 0x0000000000000240 Offset of section in file image 194 sh_size 0x0000000000000032 Size in bytes of section in file image 195 sh_link 0x00000000 Section index of associated section 196 sh_info 0x00000000 Extra info about section 197 sh_addralign 0x0000000000000001 Alignment 198 sh_entsize 0x0000000000000000 Size in bytes of each entry 199 </code></pre> 200 <h3 id="section-header-table-entry-4-symtab">Section header table: Entry 4 (.symtab)</h3> 201 <pre><code>|00000140: 1700 0000 0200 0000 0000 0000 0000 0000| ................ 202 |00000150: 0000 0000 0000 0000 8002 0000 0000 0000| ................ 203 |00000160: a800 0000 0000 0000 0500 0000 0600 0000| ................ 204 |00000170: 0800 0000 0000 0000 1800 0000 0000 0000| ................ 205 206 sh_name 0x00000017 Offset into .shstrtab 207 sh_type 0x00000002 SHT_SYMTAB 208 sh_flags 0x0000000000000000 Section attributes 209 sh_addr 0x0000000000000000 Virtual address of section in memory 210 sh_offset 0x0000000000000280 Offset of section in file image 211 sh_size 0x00000000000000a8 Size in bytes of section in file image 212 sh_link 0x00000005 Section index of associated section 213 sh_info 0x00000006 Extra info about section 214 sh_addralign 0x0000000000000008 Alignment 215 sh_entsize 0x0000000000000018 Size in bytes of each entry 216 </code></pre> 217 <h3 id="section-header-table-entry-5-strtab">Section header table: Entry 5 (.strtab)</h3> 218 <pre><code>|00000180: 1f00 0000 0300 0000 0000 0000 0000 0000| ................ 219 |00000190: 0000 0000 0000 0000 3003 0000 0000 0000| ........0....... 220 |000001a0: 1f00 0000 0000 0000 0000 0000 0000 0000| ................ 221 |000001b0: 0100 0000 0000 0000 0000 0000 0000 0000| ................ 222 223 sh_name 0x0000001f Offset into .shstrtab 224 sh_type 0x00000003 SHT_STRTAB 225 sh_flags 0x0000000000000000 Section attributes 226 sh_addr 0x0000000000000000 Virtual address of section in memory 227 sh_offset 0x0000000000000330 Offset of section in file image 228 sh_size 0x000000000000001f Size in bytes of section in file image 229 sh_link 0x00000000 Section index of associated section 230 sh_info 0x00000000 Extra info about section 231 sh_addralign 0x0000000000000001 Alignment 232 sh_entsize 0x0000000000000000 Size in bytes of each entry 233 </code></pre> 234 <h3 id="section-header-table-entry-6-relatext">Section header table: Entry 6 (.rela.text)</h3> 235 <pre><code>|000001c0: 2700 0000 0400 0000 0000 0000 0000 0000| '............... 236 |000001d0: 0000 0000 0000 0000 5003 0000 0000 0000| ........P....... 237 |000001e0: 1800 0000 0000 0000 0400 0000 0200 0000| ................ 238 |000001f0: 0800 0000 0000 0000 1800 0000 0000 0000| ................ 239 240 sh_name 0x00000027 Offset into .shstrtab 241 sh_type 0x00000004 SHT_RELA 242 sh_flags 0x0000000000000000 Section attributes 243 sh_addr 0x0000000000000000 Virtual address of section in memory 244 sh_offset 0x0000000000000350 Offset of section in file image 245 sh_size 0x0000000000000018 Size in bytes of section in file image 246 sh_link 0x00000004 Section index of associated section 247 sh_info 0x00000002 Extra info about section 248 sh_addralign 0x0000000000000008 Alignment 249 sh_entsize 0x0000000000000018 Size in bytes of each entry 250 </code></pre> 251 <h3 id="section-1-data-sht_progbits-shf_write--shf_alloc">Section 1: .data (SHT_PROGBITS; SHF_WRITE | SHF_ALLOC)</h3> 252 <pre><code>|00000200: 4865 6c6c 6f2c 2057 6f72 6c64 210a 0000| Hello, World!... 253 254 0x000000 'Hello, World!\n' 255 Zero-padding (2 bytes starting at 0x20e) 256 </code></pre> 257 <h3 id="section-2-text-sht_progbits-shf_alloc--shf_execinstr">Section 2: .text (SHT_PROGBITS; SHF_ALLOC | SHF_EXECINSTR)</h3> 258 <pre><code>|00000210: bf01 0000 0048 be00 0000 0000 0000 00ba| .....H.......... 259 |00000220: 0e00 0000 b804 0000 000f 0548 31ff b801| ...........H1... 260 |00000230: 0000 000f 0500 0000 0000 0000 0000 0000| ................ 261 262 0x00000010 mov edi, 0x1 263 0x00000015 movabs rsi, 0x000000 (placeholder for db hello) 264 0x0000001f mov edx, 0xe 265 0x00000024 mov eax, 0x4 266 0x00400029 syscall 267 0x0040002b xor rdi, rdi 268 0x0040002e mov eax, 0x1 269 0x00400033 syscall 270 Zero-padding (11 bytes starting at 0x235) 271 </code></pre> 272 <h3 id="section-3-shstrtab-sht_strtab">Section 3: .shstrtab (SHT_STRTAB;)</h3> 273 <pre><code>|00000240: 002e 6461 7461 002e 7465 7874 002e 7368| ..data..text..sh 274 |00000250: 7374 7274 6162 002e 7379 6d74 6162 002e| strtab..symtab.. 275 |00000260: 7374 7274 6162 002e 7265 6c61 2e74 6578| strtab..rela.tex 276 |00000270: 7400 0000 0000 0000 0000 0000 0000 0000| t............... 277 278 0x00000000: '' 279 0x00000001: '.data' 280 0x00000007: '.text' 281 0x0000000d: '.shstrtab' 282 0x00000017: '.symtab' 283 0x0000001f: '.strtab' 284 0x00000027: '.rela.text' 285 Zero-padding (14 bytes starting at 0x272) 286 </code></pre> 287 <h3 id="section-4-symtab-sht_symtab">Section 4: .symtab&rsquo; (SHT_SYMTAB;)</h3> 288 <h4 id="symbol-table-entry-0">Symbol table entry 0</h4> 289 <pre><code>|00000280: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 290 |00000290: 0000 0000 0000 0000 | ........ 291 292 st_name 0x00000000 293 st_info 0x00 294 st_other 0x00 295 st_shndx 0x0000 (SHN_UNDEF) 296 st_value 0x0000000000000000 297 st_size 0x0000000000000000 298 </code></pre> 299 <h4 id="symbol-table-entry-1-helloasm">Symbol table entry 1 (hello.asm)</h4> 300 <pre><code>|00000298: 0100 0000 0400 f1ff| ........ 301 |000002a0: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 302 303 st_name 0x00000001 304 st_info 0x04 (STT_FILE) 305 st_other 0x00 306 st_shndx 0xfff1 (SHN_ABS) 307 st_value 0x0000000000000000 308 st_size 0x0000000000000000 309 </code></pre> 310 <h4 id="symbol-table-entry-2">Symbol table entry 2</h4> 311 <pre><code>|000002b0: 0000 0000 0300 0100 0000 0000 0000 0000| ................ 312 |000002c0: 0000 0000 0000 0000 | ........ 313 314 st_name 0x00000000 315 st_info 0x03 (STT_OBJECT | STT_FUNC) 316 st_other 0x00 317 st_shndx 0x0001 (Section 1: .data) 318 st_value 0x0000000000000000 319 st_size 0x0000000000000000 320 </code></pre> 321 <h4 id="symbol-table-entry-3">Symbol table entry 3</h4> 322 <pre><code>|000002c8: 0000 0000 0300 0200| ........ 323 |000002d0: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 324 325 st_name 0x00000000 326 st_info 0x03 (STT_OBJECT | STT_FUNC) 327 st_other 0x00 328 st_shndx 0x0002 (Section 2: .text) 329 st_value 0x0000000000000000 330 st_size 0x0000000000000000 331 </code></pre> 332 <h4 id="symbol-table-entry-4-hello">Symbol table entry 4 (hello)</h4> 333 <pre><code>|000002e0: 0b00 0000 0000 0100 0000 0000 0000 0000| ................ 334 |000002f0: 0000 0000 0000 0000 | ........ 335 336 st_name 0x0000000b 337 st_info 0x00 338 st_other 0x00 339 st_shndx 0x0001 (Section 1: .data) 340 st_value 0x0000000000000000 341 st_size 0x0000000000000000 342 </code></pre> 343 <h3 id="symbol-table-entry-5-hbytes">Symbol table entry 5 (hbytes)</h3> 344 <pre><code>|000002f8: 1100 0000 0000 f1ff| ........ 345 |00000300: 0e00 0000 0000 0000 0000 0000 0000 0000| ................ 346 347 st_name 0x00000011 348 st_info 0x00 349 st_other 0x00 350 st_shndx 0xfff1 (SHN_ABS) 351 st_value 0x000000000000000e 352 st_size 0x0000000000000000 353 </code></pre> 354 <h4 id="symbol-table-entry-6-_start">Symbol table entry 6 (_start)</h4> 355 <pre><code>|00000310: 1800 0000 1000 0200 0000 0000 0000 0000| ................ 356 |00000320: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 357 358 st_name 0x00000018 359 st_info 0x01 (STT_OBJECT) 360 st_other 0x00 361 st_shndx 0x0002 (Section 2: .text) 362 st_value 0x0000000000000000 363 st_size 0x0000000000000000 364 Zero-padding (8 bytes starting at 0x328) 365 </code></pre> 366 <h3 id="section-5-strtab-sht_strtab">Section 5: .strtab (SHT_STRTAB;)</h3> 367 <pre><code>|00000330: 0068 656c 6c6f 2e61 736d 0068 656c 6c6f| .hello.asm.hello 368 |00000340: 0068 6279 7465 7300 5f73 7461 7274 0000| .hbytes._start.. 369 370 0x00000000: '' 371 0x00000001: 'hello.asm' 372 0x0000000b: 'hello' 373 0x00000011: 'hbytes' 374 0x00000018: '_start' 375 Zero-padding (1 byte starting at 0x34f) 376 </code></pre> 377 <h3 id="section-6-relatext-sht_rela">Section 6: .rela.text (SHT_RELA;)</h3> 378 <pre><code>|00000350: 0700 0000 0000 0000 0100 0000 0200 0000| ................ 379 |00000360: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 380 381 r_offset 0x0000000000000007 382 r_info 0x0000000200000001 (Symbol table entry 2, type R_AMD64_64) 383 r_addend 0x0000000000000000 384 Zero-padding (8 bytes starting at 0x368) 385 </code></pre> 386 <h2 id="link-to-executable-image">Link to executable image</h2> 387 <p>Next, let&rsquo;s link <code>hello.o</code> into a 64-bit ELF executable:</p> 388 <pre><code>% ld -o hello hello.o 389 </code></pre> 390 <p>This emits <code>hello</code>, a 951-byte ELF-64 executable image.</p> 391 <p>Since the linker has decided which segment each section maps into (if any) and 392 what the segment addresses are, addresses are now known for all (statically 393 linked) symbols, and address 0x0 placeholders have been replaced with actual 394 addresses. We can see this in the <code>mov</code> instruction at address 0x4000b5, which 395 now specifies an address of 0x6000d8.</p> 396 <p>Running the linked executable image through <code>xxd</code> as above and picking our 397 trusty linker &amp; loader guide back up, here we go again:</p> 398 <h3 id="elf-header-1">ELF Header</h3> 399 <pre><code>|00000000: 7f45 4c46 0201 0109 0000 0000 0000 0000| .ELF............ 400 |00000010: 0200 3e00 0100 0000 b000 4000 0000 0000| ..&gt;.......@..... 401 |00000020: 4000 0000 0000 0000 1001 0000 0000 0000| @............... 402 |00000030: 0000 0000 4000 3800 0200 4000 0600 0300| ....@.8...@..... 403 404 e_ident[EI_MAG0..EI_MAG3] 0x7f + ELF Magic 405 e_ident[EI_CLASS] 0x02 64-bit 406 e_ident[EI_DATA] 0x01 Little-endian 407 e_ident[EI_VERSION] 0x01 ELF v1 408 e_ident[EI_OSABI] 0x09 FreeBSD 409 e_ident[EI_ABIVERSION] 0x00 Unused 410 e_ident[EI_PAD] 0x0000000000 7 bytes unused padding 411 e_type 0x0002 ET_EXEC 412 e_machine 0x003e x86_64 413 e_version 0x00000001 Version 1 414 e_entry 0x00000000004000b0 Entrypoint addr 415 e_phoff 0x0000000000000040 Program header table offset in image 416 e_shoff 0x0000000000000110 Section header table offset in image 417 e_flags 0x00000000 Architecture-dependent interpretation 418 e_ehsize 0x0040 Size of this ELF header 419 e_phentsize 0x0038 Size of program header table entry 420 e_phnum 0x0002 Number of program header table entries 421 e_shentsize 0x0040 Size of section header table entry 422 e_shnum 0x0006 Number of section header table entries 423 e_shstrndx 0x0003 Index of section header for .shstrtab 424 </code></pre> 425 <h3 id="program-header-table-entry-0-pf_x--pf_r">Program header table: Entry 0 (PF_X | PF_R)</h3> 426 <pre><code>|00000040: 0100 0000 0500 0000 0000 0000 0000 0000| ................ 427 |00000050: 0000 4000 0000 0000 0000 4000 0000 0000| ..@.......@..... 428 |00000060: d500 0000 0000 0000 d500 0000 0000 0000| ................ 429 |00000070: 0000 2000 0000 0000 | .. ............. 430 431 p_type 0x00000001 PT_LOAD 432 p_flags 0x00000005 PF_X | PF_R 433 p_offset 0x00000000 Offset of segment in file image 434 p_vaddr 0x0000000000400000 Virtual address of segment in memory 435 p_paddr 0x0000000000400000 Physical address of segment 436 p_filesz 0x00000000000000d5 Size in bytes of segment in file image 437 p_memsz 0x00000000000000d5 Size in bytes of segment in memory 438 p_align 0x0000000000200000 Alignment (2MB) 439 </code></pre> 440 <h3 id="program-header-table-entry-1-pf_w--pf_r">Program header table: Entry 1 (PF_W | PF_R)</h3> 441 <pre><code>|00000078: 0100 0000 0600 0000| ........ 442 |00000080: d800 0000 0000 0000 d800 6000 0000 0000| ..........`..... 443 |00000090: d800 6000 0000 0000 0e00 0000 0000 0000| ..`............. 444 |000000a0: 0e00 0000 0000 0000 0000 2000 0000 0000| .......... ..... 445 446 p_type 0x00000001 PT_LOAD 447 p_flags 0x00000006 PF_W | PF_R 448 p_offset 0x00000000000000d8 Offset of segment in file image 449 p_vaddr 0x00000000006000d8 Virtual address of segment in memory 450 p_paddr 0x00000000006000d8 Physical address of segment 451 p_filesz 0x000000000000000e Size in bytes of segment in file image 452 p_memsz 0x000000000000000e Size in bytes of segment in memory 453 p_align 0x0000000000200000 Alignment (2MB) 454 </code></pre> 455 <h3 id="section-1-text-sht_progbits-shf_alloc--shf_execinstr">Section 1: .text (SHT_PROGBITS; SHF_ALLOC | SHF_EXECINSTR)</h3> 456 <pre><code>|000000b0: bf01 0000 0048 bed8 0060 0000 0000 00ba| .....H...`...... 457 |000000c0: 0e00 0000 b804 0000 000f 0548 31ff b801| ...........H1... 458 |000000d0: 0000 000f 05 | ..... 459 460 0x4000b0 mov edi, 0x1 461 0x4000b5 movabs rsi, 0x6000d8 462 0x4000bf mov edx, 0xe 463 0x4000c4 mov eax, 0x4 464 0x4000c9 syscall 465 0x4000cb xor rdi, rdi 466 0x4000ce mov eax, 0x1 467 0x4000d3 syscall 468 Zero-padding (5 bytes starting at 0x000000d5) 469 </code></pre> 470 <h3 id="section-2-data-sht_progbits-shf_write--shf_alloc">Section 2: .data (SHT_PROGBITS; SHF_WRITE | SHF_ALLOC)</h3> 471 <pre><code>|000000d8: 4865 6c6c 6f2c 2057| Hello, W 472 |000000e0: 6f72 6c64 210a | orld!. 473 474 0x6000d8 'Hello, World!\n' 475 </code></pre> 476 <h3 id="section-3-shstrtab-sht_strtab-1">Section 3: .shstrtab (SHT_STRTAB;)</h3> 477 <pre><code>|000000e6: 002e 7379 6d74 6162 002e| ..symtab.. 478 |000000f0: 7374 7274 6162 002e 7368 7374 7274 6162| strtab..shstrtab 479 |00000100: 002e 7465 7874 002e 6461 7461 0000 0000| ..text..data. 480 481 0x00000000: '' 482 0x00000001: '.symtab' 483 0x00000009: '.strtab' 484 0x00000011: '.shstrtab' 485 0x0000001b: '.text' 486 0x00000021: '.data' 487 Zero-padding (3 bytes starting at 0x0000010d) 488 </code></pre> 489 <h3 id="section-header-table-entry-0-null-1">Section header table: Entry 0 (null)</h3> 490 <pre><code>|00000110: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 491 |00000120: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 492 |00000130: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 493 |00000140: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 494 495 sh_name 0x00000000 Offset into .shstrtab 496 sh_type 0x00000000 SHT_NULL 497 sh_flags 0x0000000000000000 Section attributes 498 sh_addr 0x0000000000000000 Virtual address of section in memory 499 sh_offset 0x0000000000000000 Offset of section in file image 500 sh_size 0x0000000000000000 Size in bytes of section in file image 501 sh_link 0x00000000 Section index of associated section 502 sh_info 0x00000000 Extra info about section 503 sh_addralign 0x0000000000000000 Alignment 504 sh_entsize 0x0000000000000000 Size in bytes of each entry 505 </code></pre> 506 <h3 id="section-header-table-entry-1-text">Section header table: Entry 1 (.text)</h3> 507 <pre><code>|00000150: 1b00 0000 0100 0000 0600 0000 0000 0000| ................ 508 |00000160: b000 4000 0000 0000 b000 0000 0000 0000| ..@............. 509 |00000170: 2500 0000 0000 0000 0000 0000 0000 0000| %............... 510 |00000180: 1000 0000 0000 0000 0000 0000 0000 0000| ................ 511 512 sh_name 0x0000001b Offset into .shstrtab 513 sh_type 0x00000001 SHT_PROGBITS 514 sh_flags 0x00000006 SHF_ALLOC | SHF_EXECINSTR 515 sh_addr 0x00000000004000b0 Virtual address of section in memory 516 sh_offset 0x00000000000000b0 Offset of section in file image 517 sh_size 0x0000000000000025 Size in bytes of section in file image 518 sh_link 0x00000000 Section index of associated section 519 sh_info 0x00000000 Extra info about section 520 sh_addralign 0x0000000000000010 Alignment (2B) 521 sh_entsize 0x0000000000000000 Size in bytes of each entry 522 </code></pre> 523 <h3 id="section-header-table-entry-2-data">Section header table: Entry 2 (.data)</h3> 524 <pre><code>|00000190: 2100 0000 0100 0000 0300 0000 0000 0000| !............... 525 |000001a0: d800 6000 0000 0000 d800 0000 0000 0000| ..`............. 526 |000001b0: 0e00 0000 0000 0000 0000 0000 0000 0000| ................ 527 |000001c0: 0400 0000 0000 0000 0000 0000 0000 0000| ................ 528 529 sh_name 0x00000021 Offset into .shstrtab 530 sh_type 0x00000001 SHT_PROGBITS 531 sh_flags 0x0000000000000003 SHF_WRITE | SHF_ALLOC 532 sh_addr 0x00000000006000d8 Virtual address of section in memory 533 sh_offset 0x00000000000000d8 Offset of section in file image 534 sh_size 0x000000000000000e Size in bytes of section in file image 535 sh_link 0x00000000 Section index of associated section 536 sh_info 0x00000000 Extra info about section 537 sh_addralign 0x0000000000000004 Alignment (4B) 538 sh_entsize 0x0000000000000000 Size in bytes of each entry 539 </code></pre> 540 <h3 id="section-header-table-entry-3-shstrtab-1">Section header table: Entry 3 (.shstrtab)</h3> 541 <pre><code>|000001d0: 1100 0000 0300 0000 0000 0000 0000 0000| ................ 542 |000001e0: 0000 0000 0000 0000 e600 0000 0000 0000| ................ 543 |000001f0: 2700 0000 0000 0000 0000 0000 0000 0000| '............... 544 |00000200: 0100 0000 0000 0000 0000 0000 0000 0000| ................ 545 546 sh_name 0x00000011 Offset into .shstrtab 547 sh_type 0x00000003 SHT_STRTAB 548 sh_flags 0x00000000 No flags 549 sh_addr 0x0000000000000000 Virtual address of section in memory 550 sh_offset 0x00000000000000e6 Offset of section in file image 551 sh_size 0x0000000000000027 Size in bytes of section in file image 552 sh_link 0x00000000 Section index of associated section 553 sh_info 0x00000000 Extra info about section 554 sh_addralign 0x0000000000000001 Alignment (1B) 555 sh_entsize 0x0000000000000000 Size in bytes of each entry 556 </code></pre> 557 <h3 id="section-header-table-entry-4-symtab-1">Section header table: Entry 4 (.symtab)</h3> 558 <pre><code>|00000210: 0100 0000 0200 0000 0000 0000 0000 0000| ................ 559 |00000220: 0000 0000 0000 0000 9002 0000 0000 0000| ................ 560 |00000230: f000 0000 0000 0000 0500 0000 0600 0000| ................ 561 |00000240: 0800 0000 0000 0000 1800 0000 0000 0000| ................ 562 563 sh_name 0x00000001 Offset into .shstrtab 564 sh_type 0x00000002 SHT_SYMTAB 565 sh_flags 0x00000000 No flags 566 sh_addr 0x0000000000000000 Virtual address of section in memory 567 sh_offset 0x0000000000000290 Offset of section in file image 568 sh_size 0x00000000000000f0 Size in bytes of section in file image 569 sh_link 0x00000005 Section index of associated section 570 sh_info 0x00000006 Flags 571 sh_addralign 0x0000000000000008 Alignment (8B) 572 sh_entsize 0x0000000000000018 Size in bytes of each entry (24B) 573 </code></pre> 574 <h3 id="section-header-table-entry-5-strtab-1">Section header table: Entry 5 (.strtab)</h3> 575 <pre><code>|00000250: 0900 0000 0300 0000 0000 0000 0000 0000| ................ 576 |00000260: 0000 0000 0000 0000 8003 0000 0000 0000| ................ 577 |00000270: 3700 0000 0000 0000 0000 0000 0000 0000| 7............... 578 |00000280: 0100 0000 0000 0000 0000 0000 0000 0000| ................ 579 580 sh_name 0x00000009 Offset into .shstrtab 581 sh_type 0x00000003 SHT_STRTAB 582 sh_flags 0x0000000000000000 No flags 583 sh_addr 0x0000000000000000 Virtual address of section in memory 584 sh_offset 0x0000000000000380 Offset of section in file image 585 sh_size 0x0000000000000037 Size in bytes of section in file image 586 sh_link 0x00000000 Section index of associated section 587 sh_info 0x00000000 Extrac info about section 588 sh_addralign 0x0000000000000001 Alignment (1B) 589 sh_entsize 0x0000000000000000 Size in bytes of each entry 590 </code></pre> 591 <h3 id="section-4-symtab-sht_symtab-1">Section 4: .symtab (SHT_SYMTAB;)</h3> 592 <h4 id="symbol-table-entry-0-1">Symbol table entry 0</h4> 593 <pre><code>|00000290: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 594 |000002a0: 0000 0000 0000 0000 | ........ 595 596 st_name 0x00000000 597 st_info 0x00 598 st_other 0x00 599 st_shndx 0x0000 (SHN_UNDEF) 600 st_value 0x0000000000000000 601 st_size 0x0000000000000000 602 </code></pre> 603 <h4 id="symbol-table-entry-1">Symbol table entry 1</h4> 604 <pre><code>|000002a8: 0000 0000 0300 0100| ........ 605 |000002b0: b000 4000 0000 0000 0000 0000 0000 0000| ..@............. 606 607 st_name 0x00000000 608 st_info 0x03 (STT_OBJECT | STT_FUNC) 609 st_other 0x00 610 st_shndx 0x0001 (Section 1: .text) 611 st_value 0x00000000004000b0 612 st_size 0x0000000000000000 613 </code></pre> 614 <h4 id="symbol-table-entry-2-1">Symbol table entry 2</h4> 615 <pre><code>|000002c0: 0000 0000 0300 0200 d800 6000 0000 0000| ..........`..... 616 |000002d0: 0000 0000 0000 0000 | ........ 617 618 st_name 0x00000000 619 st_info 0x03 (STT_OBJECT | STT_FUNC) 620 st_other 0x00 621 st_shndx 0x0002 (Section 2: .data) 622 st_value 0x00000000006000d8 623 st_size 0x0000000000000000 624 </code></pre> 625 <h4 id="symbol-table-entry-3-helloasm">Symbol table entry 3 (hello.asm)</h4> 626 <pre><code>|000002d0: 0100 0000 0400 f1ff| ........ 627 |000002e0: 0000 0000 0000 0000 0000 0000 0000 0000| ................ 628 629 st_name 0x00000001 630 st_info 0x04 (STT_FILE) 631 st_other 0x00 632 st_shndx 0xfff1 (SHN_ABS) 633 st_value 0x0000000000000000 634 st_size 0x0000000000000000 635 </code></pre> 636 <h4 id="symbol-table-entry-4-hello-1">Symbol table entry 4 (hello)</h4> 637 <pre><code>|000002f0: 0b00 0000 0000 0200 d800 6000 0000 0000| ..........`..... 638 |00000300: 0000 0000 0000 0000 | ................ 639 640 st_name 0x0000000b 641 st_info 0x00 642 st_other 0x00 643 st_shndx 0x0002 (Section 2: .data) 644 st_value 0x00000000006000d8 645 st_size 0x0000000000000000 646 </code></pre> 647 <h4 id="symbol-table-entry-5-hbytes-1">Symbol table entry 5 (hbytes)</h4> 648 <pre><code>|00000300: 1100 0000 0000 f1ff| ........ 649 |00000310: 0e00 0000 0000 0000 0000 0000 0000 0000| ................ 650 651 st_name 0x00000011 652 st_info 0x00 653 st_other 0x00 654 st_shndx 0xfff1 (SHN_ABS) 655 st_value 0x000000000000000e 656 st_size 0x0000000000000000 657 </code></pre> 658 <h4 id="symbol-table-entry-6-_start-1">Symbol table entry 6 (_start)</h4> 659 <pre><code>|00000320: 1800 0000 1000 0100 b000 4000 0000 0000| ..........@..... 660 |00000330: 0000 0000 0000 0000 | ........ 661 662 st_name 0x00000018 663 st_info 0x10 (STB_GLOBAL) 664 st_other 0x00 665 st_shndx 0x0001 (Section 1: .text) 666 st_value 0x00000000004000b0 667 st_size 0x0000000000000000 668 </code></pre> 669 <h4 id="symbol-table-entry-7-__bss_start">Symbol table entry 7 (__bss_start)</h4> 670 <pre><code>|00000330: 1f00 0000 1000 f1ff| ........ 671 |00000340: e600 6000 0000 0000 0000 0000 0000 0000| ..`............. 672 673 st_name 0x0000001f 674 st_info 0x10 (STB_GLOBAL) 675 st_other 0x00 676 st_shndx 0xfff1 (SHN_ABS) 677 st_value 0x00000000006000e6 678 st_size 0x0000000000000000 679 </code></pre> 680 <h4 id="symbol-table-entry-8-_edata">Symbol table entry 8 (_edata)</h4> 681 <pre><code>|00000350: 2b00 0000 1000 f1ff e600 6000 0000 0000| +.........`..... 682 |00000360: 0000 0000 0000 0000 | ........ 683 684 st_name 0x0000002b 685 st_info 0x10 (STB_GLOBAL) 686 st_other 0x00 687 st_shndx 0xfff1 (SHN_ABS) 688 st_value 0x00000000006000e6 689 st_size 0x0000000000000000 690 </code></pre> 691 <h4 id="symbol-table-entry-9-_end">Symbol table entry 9 (_end)</h4> 692 <pre><code>|00000360: 3200 0000 1000 f1ff| 2....... 693 |00000370: e800 6000 0000 0000 0000 0000 0000 0000| ..`............. 694 695 st_name 0x00000032 696 st_info 0x10 (STB_GLOBAL) 697 st_other 0x00 698 st_shndx 0xfff1 (SHN_ABS) 699 st_value 0x00000000006000e8 700 st_size 0x0000000000000000 701 </code></pre> 702 <h3 id="section-6-strtab-sht_strtab">Section 6: .strtab (SHT_STRTAB;)</h3> 703 <pre><code>|00000380: 0068 656c 6c6f 2e61 736d 0068 656c 6c6f| .hello.asm.hello 704 |00000390: 0068 6279 7465 7300 5f73 7461 7274 005f| .hbytes._start._ 705 |000003a0: 5f62 7373 5f73 7461 7274 005f 6564 6174| _bss_start._edat 706 |000003b0: 6100 5f65 6e64 00 | a._end. 707 708 0x00000000: '' 709 0x00000001: 'hello.asm' 710 0x0000000b: 'hello' 711 0x00000011: 'hbytes' 712 0x00000018: '_start' 713 0x0000001f: '__bss_start' 714 0x0000002b: '_edata' 715 0x00000032: '_end' 716 </code></pre> 717 <h2 id="effect-of-stripping">Effect of stripping</h2> 718 <p>Running <code>strip</code> on the binary has the effect of dropping the <code>.symtab</code> and 719 <code>.strtab</code> sections along with their section headers and 16 bytes of data (the 720 section names <code>.symtab</code> and <code>.strtab</code>) from the <code>.shstrtab</code> section, reducing the 721 total binary size to 512 bytes.</p> 722 <h2 id="in-memory-process-image">In-memory process image</h2> 723 <p>FreeBSD uses a memory superpage size of 2MB (page size of 4kB) on x86_64. Since 724 attributes are set at the page level, read+execute program <code>.text</code> and 725 read+write <code>.data</code> are loaded into two separate segments on separate pages, as 726 laid-out by the linker.</p> 727 <p>On launch, the kernel maps the binary image into memory as specified in the 728 program header table:</p> 729 <ul> 730 <li>PHT Entry 0: The ELF header, program header table, and Section 1 (<code>.text</code>) 731 are mapped from offset 0x00 of the binary image (with length 0xd6 bytes) 732 into Segment 1 (readable, executable) at address 0x400000.</li> 733 <li>PHT Entry 1: Section 2 (<code>.data</code>) at offset 0xd8 of the binary image is 734 mapped into Segment 2 (readable, writeable) at address 0x6000d8 from offset 735 0xd8 with length 0x0e bytes.</li> 736 </ul> 737 <p>The program entrypoint is specified to be 0x4000b0, the start of the <code>.text</code> 738 section.</p> 739 <p>And that&rsquo;s it! Any corrections or comments are always welcome. Shoot me an 740 email at <a href="mailto:chris@bracken.jp">chris@bracken.jp</a>.</p> 741 </description> 742 </item> 743 744 <item> 745 <title>Installing Mozc on Ubuntu</title> 746 <link>https://chris.bracken.jp/2011/04/installing-mozc-on-ubuntu/</link> 747 <pubDate>Fri, 22 Apr 2011 00:00:00 +0000</pubDate> 748 <author>chris@bracken.jp (Chris Bracken)</author> 749 <guid>https://chris.bracken.jp/2011/04/installing-mozc-on-ubuntu/</guid> 750 <description><p>If you&rsquo;re a Japanese speaker, one of the first things you do when you install a 751 fresh Linux distribution is to install a decent <a href="https://en.wikipedia.org/wiki/Japanese_IME">Japanese IME</a>. 752 Ubuntu defaults to <a href="https://sourceforge.jp/projects/anthy/news/">Anthy</a>, but I personally prefer <a href="https://code.google.com/p/mozc/">Mozc</a>, and 753 that&rsquo;s what I&rsquo;m going to show you how to install here.</p> 754 <p><em>Update (2011-05-01):</em> Found an older <a href="https://www.youtube.com/watch?v=MfgjTCXZ2-s">video tutorial</a> on YouTube 755 which provides an alternative (and potentially more comprehensive) solution for 756 Japanese support on 10.10 using ibus instead of uim, which is the better choice 757 for newer releases.</p> 758 <p><em>Update (2011-10-25):</em> The software installation part of this process got a 759 whole lot easier in Ubuntu releases after Natty, and as noted above, I&rsquo;d 760 recommend sticking with ibus over uim.</p> 761 <h3 id="japanese-input-basics">Japanese Input Basics</h3> 762 <p>Before we get going, let&rsquo;s understand a bit about how Japanese input works on 763 computers. Japanese comprises three main character sets: the two phonetic 764 character sets, hiragana and katakana at 50 characters each, plus many 765 thousands of Kanji, each with multiple readings. Clearly a full keyboard is 766 impractical, so a mapping is required.</p> 767 <p>Input happens in two steps. First, you input the text phonetically, then you 768 convert it to a mix of kanji and kana.</p> 769 <figure><img src="https://chris.bracken.jp/post/2011-04-22-henkan.png" 770 alt="Japanese IME completion menu"> 771 </figure> 772 773 <p>Over the years, two main mechanisms evolved to input kana. The first was common 774 on old <em>wapuro</em>, and assigns a kana to each key on the keyboard—e.g. where 775 the <em>A</em> key appears on a QWERTY keyboard, you&rsquo;ll find a ち. This is how our 776 grandparents hacked out articles for the local <em>shinbun</em>, but I suspect only a 777 few die-hard traditionalists still do this. The second and more common method 778 is literal <a href="https://en.wikipedia.org/wiki/Wapuro">transliteration of roman characters into kana</a>. You 779 type <em>fujisan</em> and out comes ふじさん.</p> 780 <p>Once the phonetic kana have been input, you execute a conversion step wherein 781 the input is transformed into the appropriate mix of kanji and kana. Given the 782 large number of homonyms in Japanese, this step often involves disambiguating 783 your input by selecting the intended kanji. For example, the <em>mita</em> in <em>eiga wo 784 mita</em> (I watched a movie) is properly rendered as 観た whereas the <em>mita</em> in 785 <em>kuruma wo mita</em> (I saw a car) should be 見た, and in neither case is it <em>mita</em> 786 as in the place name <em>Mita-bashi</em> (Mita bridge) which is written 三田.</p> 787 <h3 id="some-implementation-details">Some Implementation Details</h3> 788 <p>Let&rsquo;s look at implementation. There are two main components used in inputting 789 Japanese text:</p> 790 <p>The GUI system (e.g. ibus, uim) is responsible for:</p> 791 <ol> 792 <li>Maintaining and switching the current input mode: 793 ローマ字、ひらがな、カタカナ、半額カタカナ.</li> 794 <li>Transliteration of character input into kana: <em>ku</em> into く, 795 <em>nekko</em> into ねっこ, <em>xtu</em> into っ.</li> 796 <li>Managing the text under edit (the underlined stuff) and the 797 drop-down list of transliterations.</li> 798 <li>Ancillary functions such as supplying a GUI for custom dictionary 799 management, kanji lookup by radical, etc.</li> 800 </ol> 801 <p>The transliteration engine (e.g. Anthy, Mozc) is responsible for transforming a 802 piece of input text, usually in kana form, into kanji: for example みる into 803 one of: 見る、観る、診る、視る. This involves:</p> 804 <ol> 805 <li>Breaking the input phrase into components.</li> 806 <li>Transforming each component into the appropriate best guess based on context 807 and historical input.</li> 808 <li>Supplying alternative transformations in case the best guess was incorrect.</li> 809 </ol> 810 <h3 id="why-mozc">Why Mozc?</h3> 811 <p>TL;DR: because it&rsquo;s better. Have a look at the conversion list up at the top of 812 this post. The input is <em>kinou</em>, for which there are two main conversion 813 candidates: 機能 (feature) and 昨日 (yesterday). Notice however, that it also 814 supplies several conversions for yesterday&rsquo;s date in various formats, including 815 「平成23年4月21日」 using <a href="https://en.wikipedia.org/wiki/Japanese_era_name">Japanese Era Name</a> rather than the 816 Western notation 2011. This is just one small improvement among dozens of 817 clever tricks it performs. If you&rsquo;re thinking this bears an uncanny resemblance 818 to tricks that <a href="https://www.google.com/intl/ja/ime/">Google&rsquo;s Japanese IME</a> supports, you&rsquo;re right: Mozc 819 originated from the same codebase.</p> 820 <h3 id="switching-to-mozc">Switching to Mozc</h3> 821 <p>So let&rsquo;s assume you&rsquo;re now convinced to abandon Anthy and switch to Mozc. 822 You&rsquo;ll need to make some changes. Here are the steps:</p> 823 <p>If you haven&rsquo;t yet done so, install some Japanese fonts from either Software 824 Centre or Synaptic. I&rsquo;d recommend grabbing the <em>ttf-takao</em> package.</p> 825 <p>Next up, we&rsquo;ll install and configure Mozc.</p> 826 <ol> 827 <li><strong>Install ibus-mozc:</strong> <code>sudo apt-get install ibus-mozc</code></li> 828 <li><strong>Restart the ibus daemon:</strong> <code>/usr/bin/ibus-daemon --xim -r -d</code></li> 829 <li><strong>Set your input method to mozc:</strong> 830 <ol> 831 <li>Open <em>Keyboard Input Methods</em> settings.</li> 832 <li>Select the <em>Input Method</em> tab.</li> 833 <li>From the <em>Select an input method</em> drop-down, select Japanese, then mozc from 834 the sub-menu.</li> 835 <li>Select <em>Japanese - Anthy</em> from the list, if it appears there, and click 836 <em>Remove</em>.</li> 837 </ol> 838 </li> 839 <li><strong>Optionally, remove Anthy from your system:</strong> <code>sudo apt-get autoremove anthy</code></li> 840 </ol> 841 <p>Log out, and back in. You should see an input method menu in the menu 842 bar at the top of the screen.</p> 843 <p>That&rsquo;s it, Mozcを楽しんでください!</p> 844 </description> 845 </item> 846 847 <item> 848 <title>Google Reader</title> 849 <link>https://chris.bracken.jp/2007/05/google-reader/</link> 850 <pubDate>Wed, 30 May 2007 00:00:00 +0000</pubDate> 851 <author>chris@bracken.jp (Chris Bracken)</author> 852 <guid>https://chris.bracken.jp/2007/05/google-reader/</guid> 853 <description><p>For years, I&rsquo;ve been a fan of <a href="http://inessential.com/">Brent Simmons&rsquo;</a> OS X-based feed 854 reader, <a href="http://www.newsgator.com/Individuals/NetNewsWire/">NetNewsWire</a>. It&rsquo;s a fantastic application, and I&rsquo;ve definitely 855 got my money&rsquo;s worth out of it. After partnering with <a href="http://newsgator.com/">NewsGator</a>, I 856 started using their online feed-reader on and off, with mixed 857 results. I like that it keeps my feeds in sync between my computers, 858 and that I can browse articles at lunch, but the interface is still not on par 859 with NetNewsWire itself.</p> 860 <p>While NewsGator&rsquo;s implementation was lacking, I really did like the idea of 861 dropping the desktop app altogether and going with a fully online solution, so 862 I started exploring other options. The obvious free alternative is <a href="http://www.google.com/reader/">Google 863 Reader</a>, and I have to say, I&rsquo;m impressed. While the 864 presentation isn&rsquo;t as customizable as NetNewsWire, the functionality that I use 865 is all there, and in fact, it has some extra search features that I miss on the 866 desktop. It was only when I launched NetNewsWire today and saw 290 unread 867 items, that it hit me I hadn&rsquo;t used it in almost a month. So while I look 868 forward to <a href="http://www.flickr.com/photos/hicksdesign/210309912/">NetNewsWire 3</a>, I&rsquo;m sticking to Google Reader for the time 869 being.</p> 870 <figure><img src="https://chris.bracken.jp/post/2007-05-30-google-reader.png" 871 alt="Google reader graph of usage by hour of day"> 872 </figure> 873 874 <p>I also discovered that my prime news reading hours are apparently 6:30am to 875 7:30am and 9pm to 11pm, with a strange local maximum straggling out around 876 12:30am. I&rsquo;d be curious to compare this to <em>before</em> I had a baby that woke me 877 up around that time.</p> 878 <p><em>Update (2007-06-06):</em> NetNewsWire 3.0 is now out.</p> 879 </description> 880 </item> 881 882 </channel> 883 </rss>