Skip to content

Commit 2909f32

Browse files
committed
Actually test linker script processing
The goto-cc personality does not invoke linker script processing, hence the tests located in the ansi-c folder were a no-op. Moving them to the goto-gcc folder showed that they wouldn't work as is, which is also fixed now: 1) Add the -N option so as not to generate ELF headers, which those linker scripts leave no room for. 2) Make goto-cc accept (but ignore) the -N option. (Cosmetic change only.) 3) Actually detect failure of linker script parsing by enabling warnings and testing for them. 4) Make sure ls_parse.py is available on the PATH.
1 parent 9f9ee07 commit 2909f32

File tree

13 files changed

+34
-10
lines changed

13 files changed

+34
-10
lines changed

regression/goto-gcc/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a
1515
add_custom_target(libour_archive.a ALL
1616
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a"
1717
)
18+
19+
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
20+
set_property(
21+
TEST "goto-gcc-CORE"
22+
PROPERTY ENVIRONMENT
23+
"PATH=$ENV{PATH}:$<TARGET_FILE_DIR:goto-cc>"
24+
)
25+
endif()

regression/goto-gcc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ tests.log: ../test.pl
1010

1111
else
1212
test: ../../src/goto-cc/goto-gcc
13-
@../test.pl -e -p -c ../../../src/goto-cc/goto-gcc
13+
@PATH=../../../scripts:$$PATH ../test.pl -e -p -c ../../../src/goto-cc/goto-gcc
1414

1515
tests.log: ../test.pl ../../src/goto-cc/goto-gcc
16-
@../test.pl -e -p -c ../../../src/goto-cc/goto-gcc
16+
@PATH=../../../scripts:$$PATH ../test.pl -e -p -c ../../../src/goto-cc/goto-gcc
1717

1818
../../src/goto-cc/goto-gcc: ../../src/goto-cc/goto-cc
1919
@ln -sf goto-cc ../../src/goto-cc/goto-gcc

regression/ansi-c/linker_script_start+end/main.c renamed to regression/goto-gcc/linker_script_start+end/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ extern char src_start[];
22
extern char src_end[];
33
extern char dst_start[];
44

5-
void *memcpy(void *dest, void *src, unsigned n){
5+
void *memcpy(void *dest, void *src, unsigned n)
6+
{
67
return (void *)0;
78
}
89

9-
int main(){
10+
int main()
11+
{
1012
memcpy(dst_start, src_start, (unsigned)src_end - (unsigned)src_start);
1113
return 0;
1214
}

regression/ansi-c/linker_script_start+end/test.desc renamed to regression/goto-gcc/linker_script_start+end/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
CORE
22
main.c
3-
-o out.gb -T script.ld -nostdlib
3+
-o out.gb -T script.ld -nostdlib -N -Wall
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7+
Problem parsing linker script
78
^warning: ignoring
89
^CONVERSION ERROR$
910
--

regression/ansi-c/linker_script_start+size/main.c renamed to regression/goto-gcc/linker_script_start+size/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ extern char src_start[];
22
extern char src_size[];
33
extern char dst_start[];
44

5-
void *memcpy(void *dest, void *src, unsigned n){
5+
void *memcpy(void *dest, void *src, unsigned n)
6+
{
67
return (void *)0;
78
}
89

9-
int main(){
10+
int main()
11+
{
1012
memcpy(dst_start, src_start, (unsigned)src_size);
1113
return 0;
1214
}

regression/ansi-c/linker_script_start+size/test.desc renamed to regression/goto-gcc/linker_script_start+size/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
CORE
22
main.c
3-
-o out.gb -T script.ld -nostdlib
3+
-o out.gb -T script.ld -nostdlib -N -Wall
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7+
Problem parsing linker script
78
^warning: ignoring
89
^CONVERSION ERROR$
910
--
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
extern char sym[];
22

3-
int main(){
3+
int main()
4+
{
45
int foo = (int)sym;
56
return 0;
67
}

regression/ansi-c/linker_script_symbol-only/test.desc renamed to regression/goto-gcc/linker_script_symbol-only/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
CORE
22
main.c
3-
-o out.gb -T script.ld -nostdlib
3+
-o out.gb -T script.ld -nostdlib -N -Wall
44
^EXIT=0$
55
^SIGNAL=0$
66
--
7+
Problem parsing linker script
78
^warning: ignoring
89
^CONVERSION ERROR$
910
--

src/goto-cc/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,18 @@ else()
4141
COMMAND "${CMAKE_COMMAND}" -E create_symlink
4242
goto-cc $<TARGET_FILE_DIR:goto-cc>/goto-ld
4343
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/goto-ld)
44+
add_custom_command(TARGET goto-cc
45+
POST_BUILD
46+
COMMAND "${CMAKE_COMMAND}" -E copy
47+
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/ls_parse.py
48+
$<TARGET_FILE_DIR:goto-cc>/ls_parse.py
49+
BYPRODUCTS ${CMAKE_BINARY_DIR}/bin/ls_parse.py)
4450

4551
install(
4652
FILES
4753
${CMAKE_BINARY_DIR}/bin/goto-ld
4854
${CMAKE_BINARY_DIR}/bin/goto-gcc
55+
${CMAKE_BINARY_DIR}/bin/ls_parse.py
4956
DESTINATION
5057
${CMAKE_INSTALL_BINDIR})
5158
endif()

src/goto-cc/gcc_cmdline.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ const char *gcc_options_without_argument[]=
192192
"-MP",
193193
"-MD",
194194
"-MMD",
195+
"-N",
195196
"-mno-unaligned-access",
196197
"-mthumb",
197198
"-mthumb-interwork",

0 commit comments

Comments
 (0)