[llvm-dev] How to place a variable / function at a given absolute address in memory

38 views
Skip to first unread message

yehuda marko via llvm-dev

unread,
Nov 23, 2021, 11:37:30 AM11/23/21
to llvm...@lists.llvm.org

Hello ,

 

I’m using llvm 8 , and I want to know , How to place a variable / function at a given absolute address in memory.

 

 

Re,

Yehuda Marko

 

 

Peter Smith via llvm-dev

unread,
Nov 23, 2021, 11:47:01 AM11/23/21
to yehuda marko, llvm...@lists.llvm.org

Placing a variable / function at a specific address requires the cooperation of the linker and depending on where you are running the program, the OS. The following stack-overflow question, although relating to GCC, it also can be applied to LLVM https://stackoverflow.com/questions/4067811/how-to-place-a-variable-at-a-given-absolute-address-in-memory-with-gcc

 

Essentially you need to compile the variable or function in a named section and then place the named section using a linker script, all assuming the linker you are using can support that.

 

Hope that helps

 

Peter

Mehmet Erol Sanliturk via llvm-dev

unread,
Nov 23, 2021, 12:50:54 PM11/23/21
to yehuda marko, llvm...@lists.llvm.org


Is this possible in operating systems that are used today  ?

My opinion is that you can do this only by using operating system facilities because the memory areas are managed by the
operating system and no one else ( including LLVM ) can modify these area definitions .

Mehmet Erol Sanliturk

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply all
Reply to author
Forward
0 new messages