Method and device for protecting source code of executable file

The invention provides a method for protecting a source code of an executable file. The method comprises the following steps of: acquiring a target executable and linkable format (ELF) file needing to be shelled; extracting the core part of the target ELF file, wherein the core part comprises a data segment, a code segment, a stack segment and a dynamic link table; creating a new ELF file frame; integrating the core part with a shelled part of the target file and encrypting the core part of the target ELF file; filling an integration result into the new ELF file frame according to an ELF structure; and finishing the reconstruction of a new ELF file and setting the attribute of the ELF file to be executable. The invention also provides a device for protecting a source code file of an executable file. By adopting the method and device provided by the invention, the reverse dynamic trace ability of a file protecting technology can be enhanced.