Fixups are not the same as rewriting code, they’re just fixups

Classically speaking, a linker cannot rewrite the code the compiler generated; its job is merely to resolve symbols. Of course, resolving symbols means that references to those symbols in the code generated by the compiler turn from "I don't know" to "Here it is." Somebody named George appeared to be confused by this, believing that all changes by the linker counted as "rewriting code."

Obviously if the linker weren't allowed to change anything at all, there wouldn't be much point to having a linker. For example, you wouldn't be able to access functions or variables in a separate compilation unit (for example, from a library) because the compiler doesn't know what the final address is; that's what the linker is supposed to figure out. (Indeed, if function-level linking is enabled, then even calls within a compilation unit are left as insert address here.) The linker resolves symbols and patches up code references that used to say insert address here so that they contain the actual address.

I think George took my statement a bit too literally. The linker can't change a direct call to an indirect call; that's not something that the compiler told the linker how to do. All the linker can do is patch up insert address here fixups. It can't say "Oh, I'm going to take your two mov instructions and reverse the destination registers, and then flip the arguments to the subsequent sub instruction." (I'm talking about classical linking; the introduction of link-time code generation further blurs the line between the compiler and the linker.)

George also made the common mistake not only of calling this Web site a "document from MSDN" but also applying the same description to a Microsoft Systems Journal article from 1997. The back issues of MSJ are included in MSDN as a courtesy. Neither the back issues nor the contents of this Web site are under MSDN editorial control.

Comments (18)
  1. John says:

    The first thing I thought of when I read the title was the "report" that 60% of the code in Windows Vista was going to be rewritten.  The next thing I thought of was the perception that Windows 7 is just a fixup of Windows Vista.

  2. Ben Voigt [C++ MVP] says:

    Or more simply, immediate mode operands aren’t code, they’re data (albeit inside the text segment which is marked executable).

    As a related aside, if/when this data is interpreted as code (i.e. instruction pointer is mid-instruction) bad things happen.  Unless some hacker over-enthused with efficiency and code obfuscation designed it that way.

  3. Dog says:

    > George also made the common mistake not only of calling this Web site a “document from MSDN”

    Erm, Raymond, in case you haven’t noticed, the URL of this website is ““ and it says “Welcome to MSDN Blogs” at the top of the page. While clearly this blog is not part of the “MSDN Library” it is branded as part of MSDN, so calling it a “document from MSDN” is not inaccurate.

    [Then it depends what you mean by “from MSDN”. If you mean “from a Web site that has MSDN in its URL” then, well, that could be anything. (Besides, the MSDN Web site isn’t even; it’s I prefer to think of it as meaning “from a Web site that MSDN has editorial control over.” Otherwise, you could say that all of is “from MSDN.” -Raymond]
  4. Jon says:

    Remember kids, there’s no such thing as a stupid question, unless your question involves Raymond.  Then you should be prepared to be mocked publicly.

  5. arousedboat says:

    …no such thing as a stupid question…

    It wasn’t so much a stupid question as a rather poor assumption that something that is obviously a blog should bear any sort of credibility.

    I love Raymond’s blog. Most of the stuff he posts to it is factual or at least insightful. But it is still a blog. It is not written by a professional doc writer. It is not peer reviewed.

    This should be pretty obvious.

  6. msdn != msdn says:

    Why isn’t msdn associated with Which department owns the domain?

    [The MSDN folks have nothing to do with running The blogging folks set it up behind their backs in order to have a catchy name for their site. Bloggers are renegades. -Raymond]
  7. me says:

    Raymond: "The MSDN folks have nothing to do with running"

    Might be. But, how should the average John Doe find out about this? As already mentioned, on the top, there is "Welcome to MSDN Blogs", and at the bottom, there is "© 2009 Microsoft Corporation. All rights reserved."

    I think you are asking too much from the average user, especially if that one does not read here regularly and only stumbled upon your posting via a $SEARCHENGINE search.

  8. arousedboat says:

    …how should the average John Doe find out about this?…

    The word "Blogs" should probably tip you off.

    Would you cite information on someone’s MySpace page as some sort of inside information on Fox Interactive Media just because "myspace" appears in the URL and the page is branded with MySpace logos and legal text?

  9. John says:

    It’s all so clear to me now.  Raymond is pissed off all the time because PEOPLE ARE IDIOTS!

  10. configurator says:

    Would you cite information on someone’s MySpace page as some sort of inside information on Fox Interactive Media just because "myspace" appears in the URL and the page is branded with MySpace logos and legal text?

    Of course!

    Also, on this very page, Microsoft claimed that "people are idiots". I find that very offensive and would like a formal apology from Microsoft.

  11. DWalker says:

    I would say the original poster is not off base in his assumption that everything printed here is "from MSDN".  This blog is part of the Microsoft Developer Network.  It is a network (or collection) of resources, which includes Web sites that have documentation and other content.  

    Why should the OP care who has "editorial control" over some of the content, and which parts are not "editorially controlled" by some group of people that Raymond claims he is not part of?  (Yes, I know, you would not be a member of any club that would accept you as a member…)

    I would go so far as to claim that Raymond himself is a resource that is part of the network (or collection) of resources that developers use.  Hence, Raymond is part of MSDN!  :-)

  12. DWalker says:

    Sorry, we shouldn’t lose sight of the intent of the original article.  Fixups are not the same as rewriting code.   :[)

  13. you could say that all of is "from MSDN."

    I could and I will.

  14. Jolyon Smith says:

    Of course no-one is going to think that any/all content on MySpace comes from Fox, because most people know that MySpace is just a medium through which any number of people communicate with the world.

    Similarly, in the tech world, most people know that MSDN is (ostensibly) a Microsoft community.

    The site is branded "MSDN".  It is copyright "Microsoft".  The "Terms of Use", "Trademarks" and "Privacy Statement" links ALL refer visitors to OFFICIAL Microsoft pages (Terms of Use referring specifically to the actual, Microsoft MSDN "Terms of Use").

    It really is NOT surprising that someone might think that this blog is an MSDN product, directly or indirectly.

  15. says:

    Regarding George’s actual question, he no doubt comes from a background where a Linker is not something that you see everyday. (he could be used to Visual Basic, Delphi, lots of things). So his original problem is completely forgivable.

    But where he loses his way is in treating something with "blog" in the URL as official documentation. The MySpace example above is a good one, and saying "Most people know what Myspace is" is not a defense (most people visiting this site know what a blog is).

    Saying that, if I was Raymond, I would probably try to get something added somewhere that says "this blog is NOT for beginners!".

  16. Rick C says:

    Paradice, "not actually to establish a blogging point where individuals can enrich their learns on facilitating and leveraging .NET-related activities most effectively" should’ve communicated that.

  17. Anonymous says:

    The link to George’s post is broken now.

  18. Ken Hagan says:

    Since this whole discussion appears to revolve around what you mean by "re-write" (or "MSDN"), perhaps I should insert some confusion over "linker".

    /LTCG anyone?

    Raymond’s comments are perfectly true for a traditional compiler/linker separation of powers, but Microsoft’s own offering in this area hasn’t /really/ worked that way for many years. That’s where George went wrong. He has a mental model of his tools that is a decade or two out of date.

Comments are closed.

Skip to main content