Bug 1549762 - Turn the linker inline asm into an assembly file. r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D31051

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-05-16 01:02:00 +00:00
Родитель 2076c0d6d2
Коммит 9d5285ccb9
4 изменённых файлов: 27 добавлений и 38 удалений

Просмотреть файл

@ -21,17 +21,7 @@ DEFINES['IMPL_MFBT'] = True
DisableStlWrapping()
# Avoid building the linker tests if building with icecc since it doesn't deal
# well with .incbin.
#
# A better solution would be to set ICECC=no in the environment before building
# these objects to force the local build, but moz.build lacks such a capability
# at the moment.
#
# TODO: Remove this when https://github.com/icecc/icecream/pull/463 is merged
# and in a release.
if not CONFIG['CXX_IS_ICECREAM']:
TEST_DIRS += ['tests']
TEST_DIRS += ['tests']
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']

Просмотреть файл

@ -11,37 +11,14 @@
Logging Logging::Singleton;
/**
* ZIP_DATA(FOO, "foo") defines the variables FOO and FOO_SIZE.
* The former contains the content of the "foo" file in the same directory
* as this file, and FOO_SIZE its size.
*/
/* clang-format off */
#define ZIP_DATA(name, file) \
__asm__(".global " #name "\n" \
".data\n" \
".balign 16\n" \
#name ":\n" \
" .incbin \"" SRCDIR "/" file "\"\n" \
".L" #name "_END:\n" \
" .size " #name ", .L" #name "_END-" #name \
"\n" \
".global " #name "_SIZE\n" \
".data\n" \
".balign 4\n" \
#name "_SIZE:\n" \
" .int .L" #name "_END-" #name "\n"); \
extern const unsigned char name[]; \
extern const unsigned int name##_SIZE
/* clang-format on */
/**
* test.zip is a basic test zip file with a central directory. It contains
* four entries, in the following order:
* "foo", "bar", "baz", "qux".
* The entries are going to be read out of order.
*/
ZIP_DATA(TEST_ZIP, "test.zip");
extern const unsigned char TEST_ZIP[];
extern const unsigned int TEST_ZIP_SIZE;
const char* test_entries[] = {"baz", "foo", "bar", "qux"};
/**
@ -58,7 +35,8 @@ const char* test_entries[] = {"baz", "foo", "bar", "qux"};
* zipalign if it had a data descriptor originally.
* - Fourth entry is a file "d", STOREd.
*/
ZIP_DATA(NO_CENTRAL_DIR_ZIP, "no_central_dir.zip");
extern const unsigned char NO_CENTRAL_DIR_ZIP[];
extern const unsigned int NO_CENTRAL_DIR_ZIP_SIZE;
const char* no_central_dir_entries[] = {"a", "b", "c", "d"};
TEST(Zip, TestZip)

Просмотреть файл

@ -0,0 +1,17 @@
.macro zip_data name, path
.global \name
.data
.balign 16
\name:
.incbin "\path"
.L\name\()_END:
.size \name, .L\name\()_END-\name
.global \name\()_SIZE
.data
.balign 4
\name\()_SIZE:
.int .L\name\()_END-\name
.endm
zip_data TEST_ZIP, "test.zip"
zip_data NO_CENTRAL_DIR_ZIP, "no_central_dir.zip"

Просмотреть файл

@ -11,9 +11,13 @@ UNIFIED_SOURCES += [
'TestZip.cpp',
]
SOURCES += [
'TestZipData.S',
]
LOCAL_INCLUDES += ['..']
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
DEFINES['SRCDIR'] = '"%s"' % SRCDIR
ASFLAGS += ['-I', SRCDIR]