{"id":4887,"date":"2014-03-30T16:26:16","date_gmt":"2014-03-30T16:26:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-binutils-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:26:16","modified_gmt":"2014-03-30T16:26:16","slug":"problem-about-binutils-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-binutils-collection-of-common-programming-errors\/","title":{"rendered":"problem about binutils-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d417cb1742545a5b98b64c5cfd0e663f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nfigroc<br \/>\ngcc binutils<br \/>\nI&#8217;m building binutils 2.24 on CentOS 6.5 x64. The tarball is from here: http:\/\/ftp.gnu.org\/gnu\/binutils\/binutils-2.24.tar.gz. I&#8217;ve built GMP 5.1.3, MPFR 3.1.2, MPC 1.0.2 and Make 4.0 successfully by using GCC 4.4.7. Following commands are carried out building binutils 2.24:.\/configure &#8211;with-gmp=\/usr\/local &#8211;with-mpfr=\/usr\/local &#8211;with-mpc=\/usr\/local make make checkThe testsuite reported 5 unexpected failure as following:&#8230;Running \/root\/binutils-2.24\/ld\/testsuite\/ld-elf\/elf.exp &#8230;FAIL: static<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/622606bdd7ad08e2d2e177a8a8bb507a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJeremy Salwen<br \/>\nlinux ld binutils relocation<br \/>\nRunning Debian\/Linux x86_64 with GNU ld 2.21.Quite simply, if I link withld -o main main.o \/usr\/lib\/crti.o \/usr\/lib\/crt1.o \/usr\/lib\/crtn.o -lc -lmIt works, but when I link withld -r -o main1.o main.o \/usr\/lib\/crti.o \/usr\/lib\/crt1.o \/usr\/lib\/crtn.o -lc -lmIt complainsld: cannot find -lc ld: cannot find -lmI&#8217;m not actually trying to compile code this way, but rather I&#8217;m trying to figure out why someone else&#8217;s test to see if a library exists is not working. (Thus I don&#8217;t really understand what&#8217;s go<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fc62d49d0f573d690a4a167081f1a910?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDr3vvn45ty<br \/>\nc++ linker g++ binutils<br \/>\nI only need to use the iequals case-insensitive string comparison function from the BOOST library.I am using #include &lt;boost\/algorithm\/string.hpp&gt; to import it.Is there any way that I could only import the iequals function by itself?The reason I even care (I am really just curious.) is because the compiled DLL is about 230kB if I don&#8217;t #include it and about 1.1MB if I do. It doesn&#8217;t really make much difference in this particular case how large the file is, but it seems like there is a lot<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/40231a11da5f1c627fd21d6700edddff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlvella<br \/>\nlinux gcc shared-libraries cross-compiling binutils<br \/>\nWhen developing for native platform, I can use ldd to list all the shared libraries (.so files) a binary executable I build will try to load upon start-up. But when cross-compiling, I don&#8217;t know how to get the same information. The ldd is not a normal binutils utility, like strip or ar, that can be built alongside gcc for cross compiling, but instead, it is a cryptic shell script that apparently can only run on native platform.So, using the cross-target binutils tools, is there any way to get a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/eff6548c4482380c02fd3a144fc2a206?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNathan Kidd<br \/>\nlinux g++ shared-libraries ld binutils<br \/>\nLinux: It there a way to edit a compiled shared library ?specifically I am searching on how to add the DT_SYMBOLIC flag on an already compiled binary shared library?Here is why I am asking this:our application is composed of our own libraries (static libXXX.a) some 3rd party libs (binary-only shared libraries libYYY.so)Everything is fine with the application so far.Now I have replaced our own static* libXXX.a libraries with shared libraries versions (libXXX.so).Everything compiles and links fin<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7f0ae323cd2940b3515dcc85f3f2b6bb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKrzysztof Kosinski<br \/>\ng++ ld fftw binutils<br \/>\nI have a linking problem which I cannot explain. The program contains references to FFTW functions in a file called fft.cpp. The linking command is as follows (I skipped the rest of object files):\/usr\/bin\/g++ common\/CleanerND.cpp.2.o &#8230; common\/fft.cpp.2.o-o cleaner3d -Wl,-Bstatic -Wl,-Bdynamic -lmkl_intel_lp64 -lmkl_sequential -lmkl_core-lfftw3f -lgsl -lgslcblas -lm -lglib-2.0 -lz -lm -lpthread -fopenmpThe superfluous -Wl,-Bstatic -Wl,-Bdynamic options are generated by Waf, which I use as the b<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/73c5967cf90e62b10d34b1d2d0ad3aae?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nR..<br \/>\nc gcc linker binutils<br \/>\nIs there a way with gcc and GNU binutils to mark some functions such that they will generate an error at link-time if used? My situation is that I have some library functions which I am not removing for the sake of compatibility with existing binaries, but I want to ensure that no newly-compiled binary tries to make use of the functions. I can&#8217;t just use compile-time gcc attributes because the offending code is ignoring my headers and detecting the presence of the functions with a configure scri<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/38ba39c7ba510ac2951c010c26afb6a6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nildjarn<br \/>\nc++ gcc linker c++11 binutils<br \/>\n(Environment: gcc 4.6, c++11, glibc 2.13, binutils 2.21)Please consider the follow &#8220;linking&#8221; demo for background:foo.h:#pragma once #include &lt;iostream&gt;void foo();foo1.cpp:#include &#8220;foo.h&#8221;void foo() {std::cout &lt;&lt; &#8220;foo1&#8221;; }foo2.cpp:#include &#8220;foo.h&#8221;void foo() {std::cout &lt;&lt; &#8220;foo2&#8221;; }main.cpp:#include &#8220;foo.h&#8221;int main() {foo(); }Makefile:compile: main.o foo1.o foo2.ocase1: compileg++ -o case1.x main.ocase2: compileg++ -o case2.x main.o foo1.cppcase3: compileg++ -o case3.x main.o foo1<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/1265a28e28ac02df1fdfc345bd2567f2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKONSTANTIN MALOLIN<br \/>\ngcc osx-snow-leopard binutils ar<br \/>\nBelow is the description of the issue. I marked it all as a code to avoid the implicit formatting that StackOverflow does. That is pretty annoying to have to deal with the Wiki-like markup language when I know exactly myself how I want to format my question.I am dealing with a weird toolchain issue on Macos. Here is what is going on :$ cat gmpz.cchar foo ();int main (){return foo();}$ cat libmy.cchar foo(){return 0;}I run these commands :$ gcc -c libmy.c $ gcc gmpz.c libmy.o $ file .\/a.out .\/a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f4ae7dadb114f233fe34dc54df542dca?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndy Finkenstadt<br \/>\ngcc linker ld binutils<br \/>\nThe -l option tells the linker to search the libraries in the standard dirs. And with -L, we can specify our own library directories for searching.Question: Does the sequence of order matters for the -L option too, like it does for the -l w.r.t the linker?This link: http:\/\/gcc.gnu.org\/onlinedocs\/gcc\/Link-Options.html doesn&#8217;t say much about the sequence of -L.EDIT Also, Directories specified on the commandline are searched before the defaultdirectoriesis from the man page (as pointed by Dmitry),<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6836267883ea7234253b2100f222dbbc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nosgx<br \/>\nlinux shared-libraries binutils nm<br \/>\nI want to find some external symbols, used by one shared library (.so) in another. I easily can runnm -D .\/lib_the_one.soand get list of used symbols by grepping, for example &#8216; U &#8216; (undefined symbols):U The_external_symbolNow I want to know, how many usages of some symbol is present (statically) in the whole library &#8220;lib_the_one.so&#8221;. More exact, how many direct calls are there for some external function how many times the external variable is referencedFor example, I want to know that there are<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9a557ee43dd0771a1f5abec290043a1b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nowst<br \/>\nc assembly linker compilation binutils<br \/>\nI&#8217;m hoping someone will be able to help troubleshoot what I think is a linker script issue.I&#8217;m encountering a strange problem after adding a call to a new function. Without the function call, my object files link correctly, however, with the new function call added, I get an undefined reference to a symbol from another object file (I&#8217;ve verified it is actually present using objdump).Also strangely, with the function call present, if I link all object files first using ld -r (to give a relocatabl<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e9b2f000a6ae6b518d1a0976980b3cbb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAdam<br \/>\ngnu ld undefined-reference binutils undefined-symbol<br \/>\nWhat is the difference between these errors in GNU Binutils ld ? undefined reference undefined symbolI have a good understanding of undefined reference: This occurs for example when the loader cannot find the implementation of a function. I am curious to know the cause of undefined symbol.<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>figroc gcc binutils I&#8217;m building binutils 2.24 on CentOS 6.5 x64. The tarball is from here: http:\/\/ftp.gnu.org\/gnu\/binutils\/binutils-2.24.tar.gz. I&#8217;ve built GMP 5.1.3, MPFR 3.1.2, MPC 1.0.2 and Make 4.0 successfully by using GCC 4.4.7. Following commands are carried out building binutils 2.24:.\/configure &#8211;with-gmp=\/usr\/local &#8211;with-mpfr=\/usr\/local &#8211;with-mpc=\/usr\/local make make checkThe testsuite reported 5 unexpected failure as following:&#8230;Running \/root\/binutils-2.24\/ld\/testsuite\/ld-elf\/elf.exp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4887","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4887"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4887\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}