📄 libtool
字号:
# # You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.# */# # #include <stdio.h> /* for printf() */# #include <unistd.h> /* for open(), lseek(), read() */# #include <fcntl.h> /* for O_RDONLY, O_BINARY */# #include <string.h> /* for strdup() */# # static unsigned int# pe_get16 (fd, offset)# int fd;# int offset;# {# unsigned char b[2];# lseek (fd, offset, SEEK_SET);# read (fd, b, 2);# return b[0] + (b[1]<<8);# }# # static unsigned int# pe_get32 (fd, offset)# int fd;# int offset;# {# unsigned char b[4];# lseek (fd, offset, SEEK_SET);# read (fd, b, 4);# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);# }# # static unsigned int# pe_as32 (ptr)# void *ptr;# {# unsigned char *b = ptr;# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);# }# # int# main (argc, argv)# int argc;# char *argv[];# {# int dll;# unsigned long pe_header_offset, opthdr_ofs, num_entries, i;# unsigned long export_rva, export_size, nsections, secptr, expptr;# unsigned long name_rvas, nexp;# unsigned char *expdata, *erva;# char *filename, *dll_name;# # filename = argv[1];# # dll = open(filename, O_RDONLY|O_BINARY);# if (!dll)# return 1;# # dll_name = filename;# # for (i=0; filename[i]; i++)# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':')# dll_name = filename + i +1;# # pe_header_offset = pe_get32 (dll, 0x3c);# opthdr_ofs = pe_header_offset + 4 + 20;# num_entries = pe_get32 (dll, opthdr_ofs + 92);# # if (num_entries < 1) /* no exports */# return 1;# # export_rva = pe_get32 (dll, opthdr_ofs + 96);# export_size = pe_get32 (dll, opthdr_ofs + 100);# nsections = pe_get16 (dll, pe_header_offset + 4 +2);# secptr = (pe_header_offset + 4 + 20 +# pe_get16 (dll, pe_header_offset + 4 + 16));# # expptr = 0;# for (i = 0; i < nsections; i++)# {# char sname[8];# unsigned long secptr1 = secptr + 40 * i;# unsigned long vaddr = pe_get32 (dll, secptr1 + 12);# unsigned long vsize = pe_get32 (dll, secptr1 + 16);# unsigned long fptr = pe_get32 (dll, secptr1 + 20);# lseek(dll, secptr1, SEEK_SET);# read(dll, sname, 8);# if (vaddr <= export_rva && vaddr+vsize > export_rva)# {# expptr = fptr + (export_rva - vaddr);# if (export_rva + export_size > vaddr + vsize)# export_size = vsize - (export_rva - vaddr);# break;# }# }# # expdata = (unsigned char*)malloc(export_size);# lseek (dll, expptr, SEEK_SET);# read (dll, expdata, export_size);# erva = expdata - export_rva;# # nexp = pe_as32 (expdata+24);# name_rvas = pe_as32 (expdata+32);# # printf ("EXPORTS\n");# for (i = 0; i<nexp; i++)# {# unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);# printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);# }# # return 0;# }# /* impgen.c ends here */ ;; *) allow_undefined=yes ;; esac compile_command="$nonopt" finalize_command="$nonopt" compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= linkopts= if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else lib_search_path= fi # now prepend the system-specific ones eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" avoid_version=no dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= link_against_libtool_libs= ltlibs= module=no objs= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= # We need to know -static, to get the right output filenames. for arg do case "$arg" in -all-static | -static) if test "X$arg" = "X-all-static"; then if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi else if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi fi build_libtool_libs=no build_old_libs=yes prefer_static_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test $# -gt 0; do arg="$1" shift # If the previous option needs an argument, assign it. if test -n "$prev"; then case "$prev" in output) compile_command="$compile_command @OUTPUT@" finalize_command="$finalize_command @OUTPUT@" ;; esac case "$prev" in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" finalize_command="$finalize_command @SYMFILE@" preload=yes fi case "$arg" in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= ;; esac ;; expsyms) export_symbols="$arg" if test ! -f "$arg"; then $echo "$modename: symbol file \`$arg' does not exist" exit 1 fi prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; release) if test "$release_suffix" = all; then release="$arg" elif test "$release_suffix" = yes; then release="-$arg" fi prev= continue ;; rpath | xrpath) # We need an absolute path. case "$arg" in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit 1 ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi prevarg="$arg" case "$arg" in -all-static) if test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 continue ;; -avoid-version) build_old_libs=no avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: not more than one -exported-symbols argument allowed" exit 1 fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. case "$dir" in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 absdir="$dir" fi dir="$absdir" ;; esac case " $deplibs " in *" $arg "*) ;; *) deplibs="$deplibs $arg";; esac case " $lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir";; esac case "$host" in *-*-cygwin* | *-*-mingw* | *-*-os2*) dllsearchdir=`cd "$dir" && pwd || echo "$dir"` case ":$dllsearchpath:" in ::) dllsearchpath="$dllsearchdir";; *":$dllsearchdir:"*) ;; *) dllsearchpath="$dllsearchpath:$dllsearchdir";; esac ;; esac ;; -l*) if test "$arg" = "-lc"; then case "$host" in *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) # These systems don't actually have c library (as such) continue ;; esac elif test "$arg" = "-lm"; then case "$host" in *-*-cygwin* | *-*-beos*) # These systems don't actually have math library (as such) continue ;; esac fi deplibs="$deplibs $arg" ;; -?thread) deplibs="$deplibs $arg" ;; -module) module=yes continue ;; -no-undefined) allow_undefined=no continue ;; -o) prev=output ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` # We need an absolute path. case "$dir" in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit 1 ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -static) # If we have no pic_flag, then this is the same as -all-static. if test -z "$pic_flag" && test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case "$arg" in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -