parameters: (file, section)
return_statement: return result
docstring: Return the requested ELF section of the file as a str, represented
      as a sequence of bytes.
docstring_summary: Return the requested ELF section of the file as a str, represented
      as a sequence of bytes.
docstring_tokens: Return the requested ELF section of the file as a str represented as a sequence of bytes .
function: def elf_section(file, section):
      """
      Return the requested ELF section of the file as a str, represented
      as a sequence of bytes.
      """
      # We can read the .gnu_debuglink section using either of:
      #   objdump -s --section=.gnu_debuglink $file
      #   readelf -x .gnu_debuglink $file
      # Since readelf prints things backwards on little-endian platforms
      # for some versions only (backwards on Fedora Core 6, forwards on
      # Fedora 7), use objdump.
      objdump = subprocess.Popen(['objdump', '-s', '--section=' + section, file],
                                 stdout=subprocess.PIPE,
                                 # redirect stderr so errors don't get printed
                                 stderr=subprocess.PIPE)
      (objdump_stdout, objdump_stderr) = objdump.communicate()
      if objdump.returncode != 0:
          return None
      result = ""
      # Turn hexadecimal dump into the bytes it represents
      for line in StringIO(objdump_stdout).readlines():
          m = objdump_section_re.match(line)
          if m:
              for gnum in [0, 1, 2, 3]:
                  word = m.groups()[gnum]
                  if word != "        ":
                      for idx in [0, 2, 4, 6]:
                          result += chr(int(word[idx:idx+2], 16))
      return result
function_tokens: def elf_section ( file , section ) : # We can read the .gnu_debuglink section using either of: #   objdump -s --section=.gnu_debuglink $file #   readelf -x .gnu_debuglink $file # Since readelf prints things backwards on little-endian platforms # for some versions only (backwards on Fedora Core 6, forwards on # Fedora 7), use objdump. objdump = subprocess . Popen ( [ 'objdump' , '-s' , '--section=' + section , file ] , stdout = subprocess . PIPE , # redirect stderr so errors don't get printed stderr = subprocess . PIPE ) ( objdump_stdout , objdump_stderr ) = objdump . communicate ( ) if objdump . returncode != 0 : return None result = "" # Turn hexadecimal dump into the bytes it represents for line in StringIO ( objdump_stdout ) . readlines ( ) : m = objdump_section_re . match ( line ) if m : for gnum in [ 0 , 1 , 2 , 3 ] : word = m . groups ( ) [ gnum ] if word != "        " : for idx in [ 0 , 2 , 4 , 6 ] : result += chr ( int ( word [ idx : idx + 2 ] , 16 ) ) return result