Почему таблица символов не содержит имени переменной?C++

Программы на C++. Форум разработчиков
Ответить
Гость
 Почему таблица символов не содержит имени переменной?

Сообщение Гость »


Создать

Код: Выделить всё

main.cpp
like this:

Код: Выделить всё

int main() {
int a = 1;
int b = 2;
int c = a + b;
int d = c % b;
int e = c + d;
return e;
}
Compile it:

Код: Выделить всё

clang++ -g -O0 main.cpp
Then try to see the symbol table:

Код: Выделить всё

dsymutil -s a.out
Output looks like this:

Код: Выделить всё

----------------------------------------------------------------------
Symbol table for: 'a.out' (arm64)
----------------------------------------------------------------------
Index    n_strx   n_type             n_sect n_desc n_value
======== -------- ------------------ ------ ------ ----------------
[     0] 00000001 64 (N_SO         ) 01     0000   0000000000000000
[     1] 0000001c 64 (N_SO         ) 00     0000   0000000000000000 '/Users//tmp/'
[     2] 0000002f 64 (N_SO         ) 00     0000   0000000000000000 'main.cpp'
[     3] 00000038 66 (N_OSO        ) 00     0001   0000000065ef7009 '/private/var/folders/75/7ln8mr3j3md23mts9rq7jmcw0000gn/T/main-bf85b7.o'
[     4] 00000001 2e (N_BNSYM      ) 01     0000   0000000100003f4c
[     5] 00000016 24 (N_FUN        ) 01     0000   0000000100003f4c '_main'
[     6] 00000001 24 (N_FUN        ) 00     0000   000000000000005c
[     7] 00000001 4e (N_ENSYM      ) 01     0000   0000000100003f4c
[     8] 00000001 64 (N_SO         ) 01     0000   0000000000000000
[     9] 00000002 0f (     SECT EXT) 01     0010   0000000100000000 '__mh_execute_header'
[    10] 00000016 0f (     SECT EXT) 01     0000   0000000100003f4c '_main'
None of the variables are in the symbol table. I wonder why.
Thought about these:
  • Maybe the variables are optimized away because the logic in the code is too simple. - But I gave flag which means no optimization.
  • Maybe the symbol table is never meant to have variable names. - Searched online and it seems variable names is expected to be in symbol tables.
So I'm out of guesses. Also tried to search stackoverflow for similar questions, didn't see any on the first page of search results. Sorry if this is a dupe.


Источник: https://stackoverflow.com/questions/781 ... iable-name
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»