Remove obsolete bss-related code/build features

GC for unix/windows builds doesn't make use of the bss section anymore,
so we do not need the (sometimes complicated) build features and code related to it
pull/1049/head
stijn 2015-01-08 10:32:45 +01:00
rodzic 181bfb6db2
commit afd6c8e1d2
7 zmienionych plików z 7 dodań i 137 usunięć

Wyświetl plik

@ -695,11 +695,9 @@ void gc_dump_alloc_table(void) {
case AT_FREE: c = '.'; break;
/* this prints out if the object is reachable from BSS or STACK (for unix only)
case AT_HEAD: {
extern char __bss_start, _end;
extern char *stack_top;
c = 'h';
void **ptrs = (void**)&__bss_start;
mp_uint_t len = ((mp_uint_t)&_end - (mp_uint_t)&__bss_start) / sizeof(mp_uint_t);
void **ptrs = (void**)(void*)&mp_state_ctx;
mp_uint_t len = offsetof(mp_state_ctx_t, vm.stack_top) / sizeof(mp_uint_t);
for (mp_uint_t i = 0; i < len; i++) {
mp_uint_t ptr = (mp_uint_t)ptrs[i];
if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
@ -709,7 +707,7 @@ void gc_dump_alloc_table(void) {
}
if (c == 'h') {
ptrs = (void**)&c;
len = ((mp_uint_t)stack_top - (mp_uint_t)&c) / sizeof(mp_uint_t);
len = ((mp_uint_t)MP_STATE_VM(stack_top) - (mp_uint_t)&c) / sizeof(mp_uint_t);
for (mp_uint_t i = 0; i < len; i++) {
mp_uint_t ptr = (mp_uint_t)ptrs[i];
if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {

Wyświetl plik

@ -35,8 +35,8 @@ endif
# if necessary override the value of 'CC' set in py/mkenv.mk
ifeq ($(UNAME_S),Darwin)
CC = clang
# Use clang syntax for map file and set osx specific flags
LDFLAGS_ARCH = -Wl,-order_file,$(BUILD)/order.def -Wl,-map,$@.map
# Use clang syntax for map file
LDFLAGS_ARCH = -Wl,-map,$@.map
else
# Use gcc syntax for map file
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
@ -92,17 +92,6 @@ SRC_C = \
alloc.c \
$(SRC_MOD)
ifeq ($(UNAME_S),Darwin)
# Must be the last file in list of sources
SRC_C += seg_helpers.c
# making seg_helpers.c rely on order.def will force order.def to be created
seg_helpers.c: $(BUILD)/order.def
# create order.def in build directory
$(BUILD)/order.def:
$(Q)echo "seg_helpers.o: ___bss_start" > $@
endif
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))

Wyświetl plik

@ -1,38 +0,0 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*
This is a stub used to create the symbols __bss_start and _end in a Mach-O object file.
Thoses are needed by the GC, and should point to the start and end of the bss section.
We reach this goal by linking this file last (putting _end at the end...), and using an
order file (order.def) to move __bss_start at the start of bss.
TODO: Some pragma to do it inline ?
*/
char __bss_start = 0;
char _end = 0;

Wyświetl plik

@ -37,7 +37,6 @@ SRC_C = \
realpath.c \
init.c \
sleep.c \
bss.c \
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))

Wyświetl plik

@ -1,71 +0,0 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/nlr.h"
#include "py/obj.h"
#include <windows.h>
IMAGE_NT_HEADERS *header_from_memory(const char *module) {
BYTE *base_addr = (BYTE*)GetModuleHandleA(module);
IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER*)base_addr;
return (IMAGE_NT_HEADERS*)(base_addr + dos_header->e_lfanew);
}
IMAGE_SECTION_HEADER *find_section(IMAGE_NT_HEADERS *nt_header, const char *name) {
int i;
IMAGE_SECTION_HEADER *section = IMAGE_FIRST_SECTION(nt_header);
for (i = 0; i < nt_header->FileHeader.NumberOfSections; ++i) {
if (strcmp((const char *)section->Name, name) == 0) {
return section;
}
++section;
}
return NULL;
}
void section_boundaries(IMAGE_NT_HEADERS *nt_header, IMAGE_SECTION_HEADER *section, char **start, char **end) {
if (section == NULL) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Could not lookup section boundaries"));
}
*start = (char*)(nt_header->OptionalHeader.ImageBase + section->VirtualAddress);
*end = *start + section->Misc.VirtualSize;
}
void section_boundaries_from_module(const char *module, const char *section, char **start, char **end) {
IMAGE_NT_HEADERS *nt_header = header_from_memory(module);
IMAGE_SECTION_HEADER *dsection = find_section(nt_header, section);
section_boundaries(nt_header, dsection, start, end);
}
char *bss_start = 0;
char *bss_end = 0;
//MSVC has no __bss_start and _end but we can get accurate section info from the PE header.
//The standard .bss section is appended to the standard .data section however so it cannot
//be looked up by name. To deal with that we put all uPy static variables in a named section.
void getbss() {
section_boundaries_from_module(NULL, MICROPY_PORT_BSSSECTION, &bss_start, &bss_end);
}

Wyświetl plik

@ -28,12 +28,9 @@
#include <stdio.h>
#include <windows.h>
extern void getbss();
HANDLE hSleepEvent = NULL;
void init() {
getbss();
hSleepEvent = CreateEvent(NULL, TRUE, FALSE, FALSE);
#ifdef __MINGW32__
putenv("PRINTF_EXPONENT_DIGITS=2");

Wyświetl plik

@ -166,7 +166,8 @@ void msec_sleep(double msec);
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
// Put static/global variables in sections with a known name we can lookup for the GC
// Put static/global variables in sections with a known name
// This used to be required for GC, not the case anymore but keep it as it makes the map file easier to inspect
// For this to work this header must be included by all sources, which is the case normally
#define MICROPY_PORT_DATASECTION "upydata"
#define MICROPY_PORT_BSSSECTION "upybss"
@ -183,8 +184,3 @@ void msec_sleep(double msec);
int snprintf(char *dest, size_t count, const char *format, ...);
#endif
// MingW specifics
#ifdef __MINGW32__
#define MICROPY_PORT_BSSSECTION ".bss"
#endif