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 5979613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:41:03+00:00 2026-05-22T21:41:03+00:00

void* curbrk; __asm__ __volatile__( mov .curbrk, %%rax; mov %%rax, %0 : =r (curbrk) ::

  • 0
void* curbrk;

__asm__ __volatile__(
    "mov .curbrk, %%rax;"
    "mov %%rax, %0"
        : "=r" (curbrk)
        :: "%rax"
);

Can anyone explain what this simple assembly code does? Thanks.

  • 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-22T21:41:04+00:00Added an answer on May 22, 2026 at 9:41 pm

    It copies the value of a symbol .curbrk, probably defined somewhere on assembly or a linker script into the C variable curbrk, clobbering the RAX register in the process.

    .curbrk probably points to the current end of the data segment. Glibc appears to define a similar symbol __curbrk, you are probably using some other libc (BSD?). In any case, sbrk(0) would be a more portable way of accessing that value.

    After looking at the FreeBSD crossreference, I can say it indeed points to the current end of the data segment: it is used both in brk() and sbrk(), using the HIDENAME macro to prepend a ., and it appears on amd64’s System.map (no longer true on current FreeBSD).

    Note, however, that in newer FreeBSD, brk() and sbrk() have been reimplemented to no longer depend of .curbrk, which was initialized from _end, which was supposed to come from the executable, but there was trouble when mixing LLVM’s ld and GNU ld. So brk() and sbrk() now use the kernel to initialize its internal curbrk, and no longer depend on _end. See FreeBSD PR228754 for details.

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

Sidebar

Related Questions

void (int a[]) { a[5] = 3; // this is wrong? } Can I
void foo() { //some code MyClass m(); //some more code } Does the C++
void test() { int buf[1000]; //populate buf foo(buf);//is this correct? Can we pass buf
- (void) doSomething: (id)with { int a; a = [with doSomething]; } How does
void foo (void *p); // library function; can't edit template<typename T> void Remove (T
I encountered a piece of assembly code in a C program I was trying
void FooThrow() throw(string, string) { } I have compiled the above code in g++
void weight_data::rev_seq(string &seq){ //TODO std::reverse(seq.begin(), seq.end()); } In this C++ method, I think this
void SomeClass::mySlot(MyClass *var){ ... } void SomeClass::SomeFunction(){ MyClass *myVar; QPushButton *button = new QPushButton(this);
void addNewNode (struct node *head, int n) { struct node* temp = (struct node*)

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.