CSCI 3500: Studio 19


Files are the fundamental abstraction of storage media. User data is stored in files on disks- so files must support reading and writing data, as well as facilitating the storage and location of data on disk when it is needed.

In this studio, you will:

  1. Examine ASCII text files
  2. Examine executable ELF files

Please complete the required exercises below, as well as any optional enrichment exercises that you wish to complete.

As you work through these exercises, please record your answers in a text file. When finished, submit your work by sending your text file and source code to with the phrase Files in the subject line.

Make sure that the name of each person who worked on these exercises is listed in the first answer, and make sure you number each of your responses so it is easy to match your responses with each exercise.

Required Exercises

  1. As the answer to the first exercise, list the names of the people who worked together on this studio.

  2. Files are the essential storage medium for data on a computer. Create an empty file using the touch command:

    touch test.txt

    Use the command "ls -l" to list all of the files in the current directory. What are the permissions on your new file?

  3. What is the new file size given by the ls command?

  4. Go ahead and fill your new file with at least 50 characters of text using a text editor of your choice. What is displayed in your text editor is not necessarily everything that is saved on disk. Use the xxd program to display the individual bytes of your file. Copy and paste the results.

  5. Make a few different text files with different contents. Is there anything stored in the file that would let you know that this file is an ASCII text file?

  6. Identify at least one character saved in the file that is not printed to the screen.

  7. Find a few executable files. We can also use xxd to look at the byte-level data of these files as well. Print their contents to your console- what are the first four bytes (eight hex digits) of each file?

  8. Look through your executable files- do you recognize any other data in there? Copy and paste some section of the program output and speculate about what it is.

  9. The program xxd is neat, but not very useful for analyzing executable files. Fortunately, there is a special program designed to do just that. Find an executable file and call it with the program readelf:

    readelf -h your_program

    This prints some basic information about your program. Pick out and explain two lines of this output.

  10. This tool provides a lot of output. Now call the readelf program with the "-a" flag instead of the "-h" flag. What offset does the .text segment of your program start at? Copy and paste the relevant line. Hint- look at the program segment table.

  11. What byte does the start of your main function reside? Hint- look at the symbol table.

Optional Enrichment Exercises

  1. No optional exercises