LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 4650 - size missing in mergeable section
Summary: size missing in mergeable section
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Common Code Generator Code (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-30 12:06 PDT by Rafael Ávila de Espíndola
Modified: 2010-03-06 13:59 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
A hack that fixes the bug (2.36 KB, patch)
2009-07-30 20:03 PDT, Rafael Ávila de Espíndola
Details
now it really fixes it :-) (4.67 KB, patch)
2009-07-30 21:22 PDT, Rafael Ávila de Espíndola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2009-07-30 12:06:04 PDT
Compiling
-----------------------------------------------------------
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-unknown-linux-gnu"
@foo = weak_odr constant [1 x i8] c"\01"
------------------------------------------------------------

produces
        .section        .gnu.linkonce.r.foo,"aM",@progbits

Before revision 77184 it would produce

.section        .gnu.linkonce.r.foo,"a",@progbits

This causes the gnu assembler to produce the warning:

Warning: entity size for SHF_MERGE not specified
Comment 1 Rafael Ávila de Espíndola 2009-07-30 12:24:52 PDT
FYI, gcc uses "aG".
Comment 2 Rafael Ávila de Espíndola 2009-07-30 17:12:49 PDT
A c++ testcase:

----------------------------
class foo {
 public:
  void test() {
    static const char v[1] = { 1 };
  }
};
void foobar() {
  foo rep;
  rep.test();
}
-------------------------

gcc produces

.weak _ZZN3foo4testEvE1v
.section .rodata._ZZN3foo4testEvE1v,"aG",@progbits,_ZZN3foo4testEvE1v,comdat
.type   _ZZN3foo4testEvE1v, @object
.size   _ZZN3foo4testEvE1v, 1
_ZZN3foo4testEvE1v:
.byte   1


we produce

.type   _ZZN3foo4testEvE1v,@object
.section        .gnu.linkonce.r._ZZN3foo4testEvE1v,"aM",@progbits
.weak   _ZZN3foo4testEvE1v
_ZZN3foo4testEvE1v:                             # _ZZN3foo4testEvE1v
.size   _ZZN3foo4testEvE1v, 1
.ascii  "\001"

I now think that the correct fix is to print a ", 1" in the section line after
@progbits (or to use comdat as gcc does).
Comment 3 Rafael Ávila de Espíndola 2009-07-30 20:03:55 PDT
Created attachment 3263 [details]
A hack that fixes the bug

The attached patch is a hack, but it fixes the bug and "make check" has no regressions.

What is the proper way to do this? Should I remove MergeableConst{4,8,16}?
Comment 4 Rafael Ávila de Espíndola 2009-07-30 21:22:14 PDT
Created attachment 3264 [details]
now it really fixes it :-)
Comment 5 Tomas Lindquist Olsen 2009-07-31 04:32:35 PDT
Just bumping up severity a bit, since this can also cause linker errors, not just warnings.
Comment 6 Chris Lattner 2009-07-31 11:08:13 PDT
I'm sorry, I missed this bug.  Taking a look now, sorry!
Comment 7 Chris Lattner 2009-07-31 11:17:59 PDT
I opted to go for the simple fix:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090727/083081.html

This returns us back to previous behavior.  I'd like to get further along with the section selection refactoring stuff before making it more complex.