rellermeyer / course_os

CS 439 course OS
BSD 3-Clause "New" or "Revised" License
38 stars 26 forks source link

ELF support #5

Closed rellermeyer closed 10 years ago

rellermeyer commented 10 years ago

Eventually we want to be able to read programs in ELF format and execute them. Therefore, we will need some code that allows us to "structurally parse" and understand ELF binaries.

null-sysadmin commented 10 years ago

I would like to work on this. I have found some good code for existing ELF parsers (http://www.opensource.apple.com/source/gdb/gdb-961/src/binutils/readelf.c for example), but we should look into existing objdump implementations too before we decide how we want to tackle this(http://www.opensource.apple.com/source/gdb/gdb-961/src/binutils/objdump.c). I'm open to working with a partner or two since this will be a large task that needs to get done quickly.

michaelbren commented 10 years ago

I'd also be happy to work on this.

jeremy-wenzel commented 10 years ago

I would be happy to work on it too.

On Mar 8, 2014, at 9:30, samanthaallen notifications@github.com wrote:

I would like to work on this. I have found some good code for existing ELF parsers (http://www.opensource.apple.com/source/gdb/gdb-961/src/binutils/readelf.c for example), but we should look into existing objdump implementations too before we decide how we want to tackle this(http://www.opensource.apple.com/source/gdb/gdb-961/src/binutils/objdump.c). I'm open to working with a partner or two since this will be a large task that needs to get done quickly.

— Reply to this email directly or view it on GitHub.

null-sysadmin commented 10 years ago

Cool, looks like we've got our team then. Let's talk about how we'll split the work up after spring break.

rellermeyer commented 10 years ago

ELF is a specification so I would suggest looking into the spec document rather than the binutils code since the latter is under GPL and any close resemblance could taint our license.

null-sysadmin commented 10 years ago

When would you guys like to meet and discuss how we're going to handle this? I'm free right after class tomorrow.

jeremy-wenzel commented 10 years ago

That works for me. On Mar 16, 2014 3:27 PM, "samanthaallen" notifications@github.com wrote:

When would you guys like to meet and discuss how we're going to handle this? I'm free right after class tomorrow.

Reply to this email directly or view it on GitHubhttps://github.com/rellermeyer/course_os/issues/5#issuecomment-37769216 .

null-sysadmin commented 10 years ago

Alright. Let's meet at the front of the room right after class and discuss what we're each going to work on.

jeremy-wenzel commented 10 years ago

I found some pretty good stuff that can help us kick this off. Check out these websites. They are pretty close to the same thing but I think they both help us aim in the right direction.

http://www.bottomupcs.com/elf.html

http://stackoverflow.com/questions/15993652/reading-elf-file-section-header-string-table

jeremy-wenzel commented 10 years ago

Sam, could you send me your email? Mine is wenzeljeremy15@gmail.com if you don't have it.

null-sysadmin commented 10 years ago

Mine is allen.c.samantha@utexas.edu

jeremy-wenzel commented 10 years ago

Prof., how do we parse an ELF header? More specifically, how do we find the other section headers?From what I have been able to find, I have learned that the magic number after the first 4 bytes in the file give some details about the file, but I can't seem to figure out how to find where the program/section headers are and how big they are.

rellermeyer commented 10 years ago

The header contains "pointers" to the program (e_phoff) and section header (e_shoff) tables. Is this what you are looking for? Wikipedia has a good overview of the content of the ELF header and where to find the information. Just take care that you correctly detect 32bit vs. 64bit binaries, especially when testing on an x86 box that might actually be 64bit. Some offsets are different for 64bit.

http://en.wikipedia.org/wiki/Executable_and_Linkable_Format

So after you have parsed the header you can continue to parse the tables and make sense out of the individual sections. I would create all this information as a data structure in memory so that the loader can identify how many sections of which type are available, where they are located, etc.

jeremy-wenzel commented 10 years ago

Thank you Professor! That is exactly what I needed.

On Fri, Mar 28, 2014 at 12:56 AM, Jan S. Rellermeyer < notifications@github.com> wrote:

The header contains "pointers" to the program and section header tables. Is this what you are looking for? Wikipedia has a good overview of the content of the ELF header and where to find the information. Just take care that you correctly detect 32bit vs. 64bit binaries, especially when testing on an x86 box that might actually be 64bit. Some offsets are different for 64bit.

http://en.wikipedia.org/wiki/Executable_and_Linkable_Format

Reply to this email directly or view it on GitHubhttps://github.com/rellermeyer/course_os/issues/5#issuecomment-38890893 .

jeremy-wenzel commented 10 years ago

Are we allowed/wise to use functions like getc and fopen in course_os? If we need these functions, could we just ask libc to put them in?