Base code/framework

Could someone please point me towards any documentation concerning the base code which runs behind the scenes and which eventually calls setup() and loop() ?

Do you mean main() ? Its in the with the core functions/libraries.

My path:
C:\Users\Andrew\Documents\arduino-1.5.7\hardware\arduino\avr\cores\arduino

/*
  main.cpp - Main loop for Arduino sketches
  Copyright (c) 2005-2013 Arduino Team.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <Arduino.h>

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

int main(void)
{
	init();

	initVariant();

#if defined(USBCON)
	USBDevice.attach();
#endif
	
	setup();
    
	for (;;) {
		loop();
		if (serialEventRun) serialEventRun();
	}
        
	return 0;
}

Not much to it. What you can do from here is explore Arduino.h and all the other libraries that branch off.

Ah I found it thanks. I presume that all that code and the base C library are uploaded every time I do "upload" from the Arduino IDE?

Yes, but the compiler is smart when it comes to what to upload. All those libraries have tons of functions, but the compiler only uploads the ones you need.