This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
string constant of the constant pool entry..
- From: Umesh Kalappa <umesh dot kalappa0 at gmail dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 2 Mar 2015 17:14:18 +0530
- Subject: string constant of the constant pool entry..
- Authentication-results: sourceware.org; auth=none
Hi All,
I'm trying to fetch the string constant from the constant pool entry
for the symbol_ref rtx like
c sample
int i;
int main()
{
printf("%d",i);
}
rtl is
(gdb) p debug_rtx(val)
(0xb7da4da0) (symbol_ref/f:SI ("*.LC0") [flags 0x2] <string_cst 0xb7d97558>)
corresponding asm
.section .rodata,code
.align 2
.LC0:
.ascii "%d\000"
sample code to fetch the string "%i"
tree sym = SYMBOL_REF_DECL(rtx);
if (!(sym && (TREE_CODE(sym)==STRING_CST) && STRING_CST_CHECK(sym)))
sym = 0;
const char *string = TREE_STRING_POINTER(sym);
the above sample code fails with returning null in string.
Whats wrong with the above code ? or How do we fetch the
string_constant from the given symbol_ref ?
Any hints will be appreciated ,thank you
FYI,the gcc code base is 4.8.3.
~Umesh