![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading ELF file Symbol table of C++ program | vinod_chitrali | High Level Programming | 2 | 08-02-2009 10:54 AM |
| Reading ELF file Symbol table of C++ program | vinod_chitrali | Linux | 0 | 08-01-2009 02:15 PM |
| Check the record count in table (table in oracle) | kamineni | Shell Programming and Scripting | 1 | 12-15-2008 08:31 AM |
| how to view symbol table in unix | saravanan_nitt | High Level Programming | 1 | 02-14-2008 01:02 AM |
| no symbol table | Dom_Cyrus | High Level Programming | 2 | 01-31-2006 09:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Hi.
You can use: objdump or nm. ---------- Post updated at 08:25 AM ---------- Previous update was at 08:16 AM ---------- The problem of that code is that 'p' symbol is stored in a not writable data segment because it is defined as a constant. If you compile that code, for example, with: Code:
g++ -fwritable-strings test.cpp -o test |
|
|||||
|
The line
Code:
*p='T';
This line should work: Code:
p="T"; |
|
|||||
|
Quote:
how to use the commands , i used Code:
[User@telnet spark]$ objdump -t te.o te.o: file format elf32-i386 SYMBOL TABLE: 00000000 l df *ABS* 00000000 te.c 00000000 l d .text 00000000 00000000 l d .data 00000000 00000000 l d .bss 00000000 00000000 l d .rodata 00000000 00000000 l d .comment 00000000 00000000 g O .data 00000004 p 00000000 g F .text 00000035 main 00000000 *UND* 00000000 printf i tried all but dint understand much. i want the info in following format: Code:
symbolname section address default val g rwdata ---- 0 if any global variables are present it should give U ( undefined/ defined later) Last edited by pludi; 2 Weeks Ago at 04:24 AM.. Reason: code tags added |
|
|||||
|
Try with:
Code:
objdump -s <exec> You can see the difference of the compilation with and without -fwritable-strings option. If you want to get the executable symbols table, you can use: Code:
nm -C -f sysv <exec> Last edited by pogdorica; 2 Weeks Ago at 04:27 AM.. |
|
|||||
|
MrUser, your code is problematic. Consider the following 2 statements:
Code:
char p[] = "test"; char *p = "test"; In the second statement an immutable (AKA constant) string litteral is declared and the base address of the memory where the compiler stores the string litteral is assigned to the pointer variable p. In this case, the result of *p = 'T' is undefined as you found out. When you want a mutable string, i.e. a string which can be modified, use initialization instead of assignment. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|