C/C++ and Fortran

C/C++ and Fortran

Connect, learn, share, and engage with IBM Power.

 View Only

TOC Overflow: what is it, and why should you care?

By Archive User posted Fri December 12, 2008 11:44 AM

  

Originally posted by: rauls


When building large applications on AIX or pSeries Linux you may have experienced the dreaded TOC overflow. This is a situation reported the system linker that causes it to abort and fail to generate an executable.

What is this situation and what are the strategies for coping with it?

Basically, the TOC or table-of-contents is a table that the program uses to reference global symbols. Since these symbols can be referenced from multiple object files, their memory location is unknown until link time, so the code generated by the compiler to access them must look them up in this table.

The way this works is that the ABI reserves a register which always points to the TOC. The compiler generates an indirect reference off this pointer with a zero offset, which is updated by the linker with the actual offset it selected for each global symbol. The PowerPC architecture allows up to a 64K offset, thus creating a limit of 16K global symbols on 32-bit mode and 8K on 64-bit mode. If a program has a larger number of global symbols the linker cannot reserve TOC slots for all of them, and it aborts after reporting TOC overflow.

On my next post I'll discuss some strategies for addressing this problem, and their tradeoffs. Here's a link: Dealing with TOC overflow: the traditional approach






1 comment
2 views

Permalink

Comments

Thu October 13, 2011 02:07 AM

Originally posted by: SiyuanZhang


The Chinese version of this blog can be found at: https://www.ibm.com/developerworks/mydeveloperworks/blogs/12bb75c9-dfec-42f5-8b55-b669cc56ad76/entry/toc_e8_a1_a8_e6_ba_a2_e5_87_ba_e6_98_af_e4_bb_80_e4_b9_88__e4_b8_ba_e4_bb_80_e4_b9_88_e8_a6_81_e5_85_b3_e5_bf_83_e5_ae_83?lang=en