Search code examples
assemblyx86elfgnu-assembler

How to export a symbol with type "FUNC" and "GLOBAL" in gas assembly code?


The test is on 32bit x86 Linux.

This question is similar with this question.

Generally, I defined a function foo in my at&t syntax assembly code and I want to export it as "global function".

I tried this:

 .globl foo
 foo:
 ....

Then I tried to use check the symbol table with:

gcc test.s
readelf -s a.out | grep foo

However, the result is:

9981: 08061d49     0 NOTYPE  GLOBAL DEFAULT   13 config_check_cond

The type info shows NOTYPE and I want to adjust it into type FUNC, can anyone tell me how to adjust it?


Solution

  • Use the .type directive to mark it as a function, such as .type foo, @function. You can find further details in the manual.