parameters: (executable)
return_statement: return ok
docstring: Check for position independent executable (PIE), allowing for address space randomization.
docstring_summary: Check for position independent executable (PIE), allowing for address space randomization.
docstring_tokens: Check for position independent executable ( PIE ) allowing for address space randomization .
function: def check_ELF_PIE(executable):
      '''
      Check for position independent executable (PIE), allowing for address space randomization.
      '''
      p = subprocess.Popen([READELF_CMD, '-h', '-W', executable],
                           stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
      (stdout, stderr) = p.communicate()
      if p.returncode:
          raise IOError('Error opening file')
  
      ok = False
      for line in stdout.split(b'\n'):
          line = line.split()
          if len(line) >= 2 and line[0] == b'Type:' and line[1] == b'DYN':
              ok = True
      return ok
function_tokens: def check_ELF_PIE ( executable ) : p = subprocess . Popen ( [ READELF_CMD , '-h' , '-W' , executable ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE , stdin = subprocess . PIPE ) ( stdout , stderr ) = p . communicate ( ) if p . returncode : raise IOError ( 'Error opening file' ) ok = False for line in stdout . split ( b'\n' ) : line = line . split ( ) if len ( line ) >= 2 and line [ 0 ] == b'Type:' and line [ 1 ] == b'DYN' : ok = True return ok