Summary: | ld -r silently renames sections | ||
---|---|---|---|
Product: | binutils | Reporter: | Jan Beulich <jbeulich> |
Component: | ld | Assignee: | unassigned |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bug-binutils |
Priority: | P2 | ||
Version: | 2.15 | ||
Target Milestone: | --- | ||
Host: | i686-pc-linux-gnu | Target: | i686-pc-linux-gnu |
Build: | i686-pc-linux-gnu | Last reconfirmed: |
Description
Jan Beulich
2004-08-27 14:06:57 UTC
Ian's comment isn't exactly right. Current ld behaviour is as he says it should be, that is, two orphan sections with the same name and compatible flags will be linked to the same output section. Since I also think current ld behaviour is correct, I'm closing this bug report. Note the difference between the original description and your response: The original text is talking about a difference in allocation flags (one section has the SHF_ALLOC flag set, the other [identically named in another object file] doesn't), while you're talking about compatible flags (which these aren't). The thing is that current behavior results in entirely different behavior when, using in both cases the same linker script mentioning the questionable section, (a) linking the original object files into an executable and (b) combining the original object files into intermediate object files and only then linking those into an executable. I continue to believe that in these two scenarios the outcome should be the same, requiring that the linker does not rename one of the two input sections when using -r. I understand your original description, and still think current ld behaviour is correct. Many people seem to think that "ld -r" can be used much like "ar" to package a group of objects together, and that the resultant object will link into a final executable to produce the same result as if the original objects were directly linked. This is *not* true in general. I can't judge whether or under what conditions this might not be true, but I can't immediately see why it wouldn't be. Independent of that, (silently) renaming a section seems unacceptable to me. The more that in ELF one doesn't even have to, since sections are not solely identified by their name, but instead the pair (name, flags) serves as the full identification. Thus I believe that not only the renaming is a problem in ld, but also the combining of what you call compatible sections (instead, if names match but flags are different, two output sections should be generated). http://sources.redhat.com/ml/binutils/2004-10/msg00178.html It might be reasonable to change ld -r so that an attempt to combine two input sections with incompatible flags results in two output sections of the same name. Fixed in 2.20 |