Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
usage of linker commands for clang static analysis

I am developing a static analysis tool with python-clang-3.6 library that would let me to draw function call-graphs.

To properly create TranslationUnit I need to use corresponding compile command (i.e. clang.cindex.Index.parse(c_file, compile_command) ). However, I believe, to be able to properly interconnect TranslationUnits I would also need to use linker commands to know which TranslationUnit uses functions from other TranslationUnits. This is a problem in my project where there are actually multiple binaries being built with a single "make" invocation and some TranslationUnits might possibly have colliding symbol names, so I can't assume that all of them are inter-connected.

What is the best way to address this issue so that my tool would know which functions in C file could call functions from other C files?

For now I see two options:

  1. Somehow retrieve and use linker commands; This option seems tricky because it is not directly supported in clang (at least clang python library); or
  2. At the time when traversing TranslationUnit's AST tree remember the location of function declaration in the Header file. This option seems tricky if due to macro processing I would get different line numbers or have implicit function declarations for different TranslationUnits.

Are there any other options? Which option and why would chose you?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I'm not sure if it's necessary to extract the information from the sources using clang, or if you can simply extract the information from the resulting binaries.

If you want to see the symbols used in the binary you could use

readelf -s <file>

This lists the symbol table and you can extract if the symbol is provided by the binary or is required (imported).

Using

readelf -d <file> | grep NEEDED

you get a list of dependent libraries.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda