📄 objcopy.1
字号:
\&\fBreadonly\fR, \fBcode\fR, \fBdata\fR, \fBrom\fR, \fBshare\fR, and\&\fBdebug\fR. You can set the \fBcontents\fR flag for a section whichdoes not have contents, but it is not meaningful to clear the\&\fBcontents\fR flag of a section which does have contents\*(--just removethe section instead. Not all flags are meaningful for all object fileformats..IP "\fB\-\-add\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4.IX Item "--add-section sectionname=filename"Add a new section named \fIsectionname\fR while copying the file. Thecontents of the new section are taken from the file \fIfilename\fR. Thesize of the section will be the size of the file. This option onlyworks on file formats which can support sections with arbitrary names..IP "\fB\-\-rename\-section\fR \fIoldname\fR\fB=\fR\fInewname\fR\fB[,\fR\fIflags\fR\fB]\fR" 4.IX Item "--rename-section oldname=newname[,flags]"Rename a section from \fIoldname\fR to \fInewname\fR, optionallychanging the section's flags to \fIflags\fR in the process. This hasthe advantage over usng a linker script to perform the rename in thatthe output stays as an object file and does not become a linkedexecutable..SpThis option is particularly helpful when the input format is binary,since this will always create a section called .data. If for example,you wanted instead to create a section called .rodata containing binarydata you could use the following command line to achieve it:.Sp.Vb 3\& objcopy -I binary -O <output_format> -B <architecture> \e\& --rename-section .data=.rodata,alloc,load,readonly,data,contents \e\& <input_binary_file> <output_object_file>.Ve.IP "\fB\-\-change\-leading\-char\fR" 4.IX Item "--change-leading-char"Some object file formats use special characters at the start ofsymbols. The most common such character is underscore, which compilersoften add before every symbol. This option tells \fBobjcopy\fR tochange the leading character of every symbol when it converts betweenobject file formats. If the object file formats use the same leadingcharacter, this option has no effect. Otherwise, it will add acharacter, or remove a character, or change a character, asappropriate..IP "\fB\-\-remove\-leading\-char\fR" 4.IX Item "--remove-leading-char"If the first character of a global symbol is a special symbol leadingcharacter used by the object file format, remove the character. Themost common symbol leading character is underscore. This option willremove a leading underscore from all global symbols. This can be usefulif you want to link together objects of different file formats withdifferent conventions for symbol names. This is different from\&\fB\-\-change\-leading\-char\fR because it always changes the symbol namewhen appropriate, regardless of the object file format of the outputfile..IP "\fB\-\-srec\-len=\fR\fIival\fR" 4.IX Item "--srec-len=ival"Meaningful only for srec output. Set the maximum length of the Srecordsbeing produced to \fIival\fR. This length covers both address, data andcrc fields..IP "\fB\-\-srec\-forceS3\fR" 4.IX Item "--srec-forceS3"Meaningful only for srec output. Avoid generation of S1/S2 records, creating S3\-only record format..IP "\fB\-\-redefine\-sym\fR \fIold\fR\fB=\fR\fInew\fR" 4.IX Item "--redefine-sym old=new"Change the name of a symbol \fIold\fR, to \fInew\fR. This can be usefulwhen one is trying link two things together for which you have nosource, and there are name collisions..IP "\fB\-\-redefine\-syms=\fR\fIfilename\fR" 4.IX Item "--redefine-syms=filename"Apply \fB\-\-redefine\-sym\fR to each symbol pair "\fIold\fR \fInew\fR"listed in the file \fIfilename\fR. \fIfilename\fR is simply a flat file,with one symbol pair per line. Line comments may be introduced by the hashcharacter. This option may be given more than once..IP "\fB\-\-weaken\fR" 4.IX Item "--weaken"Change all global symbols in the file to be weak. This can be usefulwhen building an object which will be linked against other objects usingthe \fB\-R\fR option to the linker. This option is only effective whenusing an object file format which supports weak symbols..IP "\fB\-\-keep\-symbols=\fR\fIfilename\fR" 4.IX Item "--keep-symbols=filename"Apply \fB\-\-keep\-symbol\fR option to each symbol listed in the file\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbolname per line. Line comments may be introduced by the hash character.This option may be given more than once..IP "\fB\-\-strip\-symbols=\fR\fIfilename\fR" 4.IX Item "--strip-symbols=filename"Apply \fB\-\-strip\-symbol\fR option to each symbol listed in the file\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbolname per line. Line comments may be introduced by the hash character.This option may be given more than once..IP "\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR" 4.IX Item "--strip-unneeded-symbols=filename"Apply \fB\-\-strip\-unneeded\-symbol\fR option to each symbol listed inthe file \fIfilename\fR. \fIfilename\fR is simply a flat file, with onesymbol name per line. Line comments may be introduced by the hashcharacter. This option may be given more than once..IP "\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR" 4.IX Item "--keep-global-symbols=filename"Apply \fB\-\-keep\-global\-symbol\fR option to each symbol listed in thefile \fIfilename\fR. \fIfilename\fR is simply a flat file, with onesymbol name per line. Line comments may be introduced by the hashcharacter. This option may be given more than once..IP "\fB\-\-localize\-symbols=\fR\fIfilename\fR" 4.IX Item "--localize-symbols=filename"Apply \fB\-\-localize\-symbol\fR option to each symbol listed in the file\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbolname per line. Line comments may be introduced by the hash character.This option may be given more than once..IP "\fB\-\-globalize\-symbols=\fR\fIfilename\fR" 4.IX Item "--globalize-symbols=filename"Apply \fB\-\-globalize\-symbol\fR option to each symbol listed in the file\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbolname per line. Line comments may be introduced by the hash character.This option may be given more than once..IP "\fB\-\-weaken\-symbols=\fR\fIfilename\fR" 4.IX Item "--weaken-symbols=filename"Apply \fB\-\-weaken\-symbol\fR option to each symbol listed in the file\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbolname per line. Line comments may be introduced by the hash character.This option may be given more than once..IP "\fB\-\-alt\-machine\-code=\fR\fIindex\fR" 4.IX Item "--alt-machine-code=index"If the output architecture has alternate machine codes, use the\&\fIindex\fRth code instead of the default one. This is useful in casea machine is assigned an official code and the tool-chain adopts the new code, but other applications still depend on the original codebeing used. For \s-1ELF\s0 based architectures if the \fIindex\fRalternative does not exist then the value is treated as an absolutenumber to be stored in the e_machine field of the \s-1ELF\s0 header..IP "\fB\-\-writable\-text\fR" 4.IX Item "--writable-text"Mark the output text as writable. This option isn't meaningful for allobject file formats..IP "\fB\-\-readonly\-text\fR" 4.IX Item "--readonly-text"Make the output text write protected. This option isn't meaningful for allobject file formats..IP "\fB\-\-pure\fR" 4.IX Item "--pure"Mark the output file as demand paged. This option isn't meaningful for allobject file formats..IP "\fB\-\-impure\fR" 4.IX Item "--impure"Mark the output file as impure. This option isn't meaningful for allobject file formats..IP "\fB\-\-prefix\-symbols=\fR\fIstring\fR" 4.IX Item "--prefix-symbols=string"Prefix all symbols in the output file with \fIstring\fR..IP "\fB\-\-prefix\-sections=\fR\fIstring\fR" 4.IX Item "--prefix-sections=string"Prefix all section names in the output file with \fIstring\fR..IP "\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR" 4.IX Item "--prefix-alloc-sections=string"Prefix all the names of all allocated sections in the output file with\&\fIstring\fR..IP "\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR" 4.IX Item "--add-gnu-debuglink=path-to-file"Creates a .gnu_debuglink section which contains a reference to \fIpath-to-file\fRand adds it to the output file..IP "\fB\-\-keep\-file\-symbols\fR" 4.IX Item "--keep-file-symbols"When stripping a file, perhaps with \fB\-\-strip\-debug\fR or\&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names,which would otherwise get stripped..IP "\fB\-\-only\-keep\-debug\fR" 4.IX Item "--only-keep-debug"Strip a file, removing contents of any sections that would not bestripped by \fB\-\-strip\-debug\fR and leaving the debugging sectionsintact..SpThe intention is that this option will be used in conjunction with\&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One astripped binary which will occupy less space in \s-1RAM\s0 and in adistribution and the second a debugging information file which is onlyneeded if debugging abilities are required. The suggested procedureto create these files is as follows:.RS 4.IP "1.<Link the executable as normal. Assuming that is is called>" 4.IX Item "1.<Link the executable as normal. Assuming that is is called>"\&\f(CW\*(C`foo\*(C'\fR then....ie n .IP "1.<Run ""objcopy \-\-only\-keep\-debug foo foo.dbg"" to>" 4.el .IP "1.<Run \f(CWobjcopy \-\-only\-keep\-debug foo foo.dbg\fR to>" 4.IX Item "1.<Run objcopy --only-keep-debug foo foo.dbg to>"create a file containing the debugging info..ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"" to create a>" 4.el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR to create a>" 4.IX Item "1.<Run objcopy --strip-debug foo to create a>"stripped executable..ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.dbg foo"">" 4.el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.dbg foo\fR>" 4.IX Item "1.<Run objcopy --add-gnu-debuglink=foo.dbg foo>"to add a link to the debugging info into the stripped executable..RE.RS 4.SpNote \- the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug infofile is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step isoptional. You could instead do this:.IP "1.<Link the executable as normal.>" 4.IX Item "1.<Link the executable as normal.>".PD 0.ie n .IP "1.<Copy ""foo""\fR to \f(CW""foo.full"">" 4.el .IP "1.<Copy \f(CWfoo\fR to \f(CWfoo.full\fR>" 4.IX Item "1.<Copy foo to foo.full>".ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"">" 4.el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR>" 4.IX Item "1.<Run objcopy --strip-debug foo>".ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.full foo"">" 4.el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.full foo\fR>" 4.IX Item "1.<Run objcopy --add-gnu-debuglink=foo.full foo>".RE.RS 4.PD.Spi.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be thefull executable. It does not have to be a file created by the\&\fB\-\-only\-keep\-debug\fR switch..RE.IP "\fB\-V\fR" 4.IX Item "-V".PD 0.IP "\fB\-\-version\fR" 4.IX Item "--version".PDShow the version number of \fBobjcopy\fR..IP "\fB\-v\fR" 4.IX Item "-v".PD 0.IP "\fB\-\-verbose\fR" 4.IX Item "--verbose".PDVerbose output: list all object files modified. In the case ofarchives, \fBobjcopy \-V\fR lists all members of the archive..IP "\fB\-\-help\fR" 4.IX Item "--help"Show a summary of the options to \fBobjcopy\fR..IP "\fB\-\-info\fR" 4.IX Item "--info"Display a list showing all architectures and object formats available..IP "\fB@\fR\fIfile\fR" 4.IX Item "@file"Read command-line options from \fIfile\fR. The options read areinserted in place of the original @\fIfile\fR option. If \fIfile\fRdoes not exist, or cannot be read, then the option will be treatedliterally, and not removed. .SpOptions in \fIfile\fR are separated by whitespace. A whitespacecharacter may be included in an option by surrounding the entireoption in either single or double quotes. Any character (including abackslash) may be included by prefixing the character to be includedwith a backslash. The \fIfile\fR may itself contain additional@\fIfile\fR options; any such options will be processed recursively..SH "SEE ALSO".IX Header "SEE ALSO"\&\fIld\fR\|(1), \fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR..SH "COPYRIGHT".IX Header "COPYRIGHT"Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc..PPPermission is granted to copy, distribute and/or modify this documentunder the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1or any later version published by the Free Software Foundation;with no Invariant Sections, with no Front-Cover Texts, and with noBack-Cover Texts. A copy of the license is included in thesection entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -