Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:19:33+00:00 2026-05-30T11:19:33+00:00

I have some assembly that needs to load a C symbol in OS X

  • 0

I have some assembly that needs to load a C symbol in OS X (x86-64). With x86, the way you do this is:

mov rax, some_symbol_name

However, with x86-64, this causes a link warning:

ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _main from Test2.o.
To fix this warning, don’t compile with -mdynamic-no-pic or link with -Wl,-no_pie

Note: I know what PIE is, and I don’t want to disable it. Here are some of my other attempts to load the symbol address into a register:

movq rax, some_symbol_name          ; Link warning
lea rax, [rel some_symbol_name]     ; No link warning, but doesn't always get correct address

I’m really stumped on this (seemingly) simple problem. I’ve looked at the GAS disassembly, and it seems to be doing something along the lines of the lea above, but I can’t get NASM to generate the right code.

EDIT: For reference, this is the assembly code generated by GAS:

leaq    some_symbol_name(%rip), %rax
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:19:34+00:00Added an answer on May 30, 2026 at 11:19 am

    You want to force NASM to use RIP relative addressing. Do one of:

    lea rax, [rel some_symbol_name]
    

    or:

    default rel
    lea rax, [some_symbol_name]
    

    If this doesn’t work, post the machine code generated by both NASM and GAS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Javascript code that will programmatically register an COM interop assembly by
We have a managed app, that uses an assembly. That assembly uses some unmanaged
I have a custom MSBuild task that peeks inside an assembly to get some
I have got some code to load an assembly and get all types, which
I have this kind of code in some applications (from microsoft) [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( Microsoft.Naming,
I have some code that needs to be able to find the version number
I'm developing a SP 2010 Visual Web Part that needs to load some data
Any assembly interpreters out there? What I'm looking for: I have some assembly firmware
I have some very simple code to generate an assembly and invoke a method
I have some ASP.NET Master Pages located in one assembly. I need to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.