{"id":854,"date":"2009-01-09T23:54:30","date_gmt":"2009-01-10T07:54:30","guid":{"rendered":"http:\/\/multimedia.cx\/eggs\/?p=854"},"modified":"2020-07-25T23:39:57","modified_gmt":"2020-07-26T06:39:57","slug":"adventures-in-mips-tools","status":"publish","type":"post","link":"https:\/\/multimedia.cx\/eggs\/adventures-in-mips-tools\/","title":{"rendered":"Adventures In MIPS Tools"},"content":{"rendered":"<p>I&#8217;m trying to compile a program that will run on <a href=\"http:\/\/multimedia.cx\/eggs\/got-a-cheap-mips-subnotebook\/\">my new MIPS-based subnotebook<\/a>. I finally got a cross-compiling toolchain built and building a super-simple C program. But the program failed to run. When I tried to run my sample program, the shell complained about not knowing what to do with a &#8216;(&#8216; character. Puzzling.<\/p>\n<p>This is the &#8216;file&#8217; type of my compiled program:<\/p>\n<blockquote><p>\nELF 32-bit <strong>MSB<\/strong> executable, MIPS, MIPS-I version 1 (SYSV), statically linked, not stripped<\/p><\/blockquote>\n<p>I finally thought to extract a binary from the MIPS machine and check its file type:<\/p>\n<blockquote><p>ELF 32-bit <strong>LSB<\/strong> executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), stripped<\/p><\/blockquote>\n<p>Okay, I think I&#8217;m getting wise to the discrepancy already. It turns out that I want a target called &#8220;mipsel&#8221; rather than just plain &#8220;mips&#8221; as the former specifies little endian (and because a MIPS CPU can be wired to run either endian &#8212; that&#8217;s how simple and reduced this reduced instruction set is).<\/p>\n<p>So I rebuilt the toolchain using the &#8216;mipsel&#8217; target (building the toolchain is surprisingly quick when you know how). Now the test program segfaults when I try to run it. That&#8217;s unfortunate, though I still perceive it to be a step up from the last position. This is the new type reported by &#8216;file&#8217;:<\/p>\n<blockquote><p>\nELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), statically linked, not stripped\n<\/p><\/blockquote>\n<p>It&#8217;s MIPS-I version 1, vs. simply MIPS version 1, which is what the existing binaries are. I wonder if that&#8217;s the problem? I&#8217;m also struggling with a linker warning about the start location. That&#8217;s more likely to be the issue.<\/p>\n<p>BTW, this is the C code I am testing with:<\/p>\n<pre>\r\nint main()\r\n{\r\n  return 77;\r\n}\r\n<\/pre>\n<p>My thinking here is that I should be able to run the program followed by &#8220;echo $?&#8221; to get the last command&#8217;s exit status&#8211; 77 in this case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trying to get my first MIPS program cross-compiled<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[111,125,126],"class_list":["post-854","post","type-post","status-publish","format-standard","hentry","category-programming","tag-mips","tag-netbook","tag-subnotebook"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/comments?post=854"}],"version-history":[{"count":11,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/854\/revisions"}],"predecessor-version":[{"id":4635,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/posts\/854\/revisions\/4635"}],"wp:attachment":[{"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/media?parent=854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/categories?post=854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/multimedia.cx\/eggs\/wp-json\/wp\/v2\/tags?post=854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}