You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is very similar to issue #135.
If we try to compile the example below with the "-ffunction-sections
-fdata-sections" gcc flags enabled, we get assembler errors:
{{{
#include <string>
void test01(void)
{
const std::string str_01("point bolivar, texas");
char str_lit01[] = "point bolivar, texas";
std::string str03;
std::string str05;
const int len1 = sizeof(str_lit01)/sizeof(char);
str05.append(str03.begin(), str03.end());
}
int main()
{
test01();
return 0;
}
}}}
The assembler errors are, as follows:
/tmp/ccDgHJpg.s:209: Error: can't resolve `.text' {.text section} -
`.LK._Z6test01v' {.text._Z6test01v section}
/tmp/ccDgHJpg.s:211: Error: can't resolve `.text' {.text section} -
`.LK._Z6test01v' {.text._Z6test01v section}
/tmp/ccDgHJpg.s:213: Error: can't resolve `.text' {.text section} -
`.LK._Z6test01v' {.text._Z6test01v section}
/tmp/ccDgHJpg.s:215: Error: can't resolve `.text' {.text section} -
`.LK._Z6test01v' {.text._Z6test01v section}
Because of this issue, a couple of libstdc++ testcases fail (one of such
testcases is
"libstdc++-v3/testsuite/21_strings/char_traits/requirements/char/1.cc").
Original issue reported on code.google.com by [email protected] on 14 Jul 2009 at 2:52
The text was updated successfully, but these errors were encountered:
If we check the assembler code of the second example (i.e. the one that compiles
successfully), we can see the following lines, among others:
{{{
text
align 16
.LC3:
str "point bolivar, texas TEST\000"
section .text._Z6test01v, "xr"
align 16
.LC7:
str "point bolivar, texas\000"
}}}
On the other hand, if we check the assembler code of the first example (i.e.
the one
that fails to compile), there is only one definition of the string constant:
{{{
text
align 16
.LC3:
str "point bolivar, texas\000"
section .text._Z6test01v, "xr"
}}}
The constant is defined only in the ".text" section! There is of course nothing
wrong
with defining the constant value only once, the problem is because we try to
access
that value directly from a different section. This triggers the assembler error.
Another interesting fact: the "const std::string str_01("point bolivar, texas");
" generates an assembly code which compiles correctly. This code references the
"point bolivar, texas\000" value indirectly: first, it loads the address of the
value
which is then used to reference the value.
So, replacing the direct referencing of the constant value which is located in a
different section with indirect referencing would solve the problem.
Original issue reported on code.google.com by
[email protected]
on 14 Jul 2009 at 2:52The text was updated successfully, but these errors were encountered: