Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: libvpx/source/libvpx/build/make/obj_int_extract.c

Issue 7624054: Revert r97185 "Update libvpx snapshot to v0.9.7-p1 (Cayuga)." (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libvpx/source/libvpx/build/make/gen_msvs_proj.sh ('k') | libvpx/source/libvpx/configure » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libvpx/source/libvpx/build/make/obj_int_extract.c
diff --git a/libvpx/source/libvpx/build/make/obj_int_extract.c b/libvpx/source/libvpx/build/make/obj_int_extract.c
index 04e14a6c8134cf205f0792ac232708bdfb899d91..c46d9d58ba0daa53243ac0824b5a1e5121877a81 100644
--- a/libvpx/source/libvpx/build/make/obj_int_extract.c
+++ b/libvpx/source/libvpx/build/make/obj_int_extract.c
@@ -9,13 +9,25 @@
*/
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include "vpx_config.h"
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#include <io.h>
+#include <share.h>
#include "vpx/vpx_integer.h"
+#else
+#include <stdint.h>
+#include <unistd.h>
+#endif
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdarg.h>
typedef enum
{
@@ -35,6 +47,7 @@ int log_msg(const char *fmt, ...)
}
#if defined(__GNUC__) && __GNUC__
+
#if defined(__MACH__)
#include <mach-o/loader.h>
@@ -212,6 +225,73 @@ bail:
}
+int main(int argc, char **argv)
+{
+ int fd;
+ char *f;
+ struct stat stat_buf;
+ uint8_t *file_buf;
+ int res;
+
+ if (argc < 2 || argc > 3)
+ {
+ fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
+ fprintf(stderr, " <obj file>\tMachO format object file to parse\n");
+ fprintf(stderr, "Output Formats:\n");
+ fprintf(stderr, " gas - compatible with GNU assembler\n");
+ fprintf(stderr, " rvds - compatible with armasm\n");
+ goto bail;
+ }
+
+ f = argv[2];
+
+ if (!((!strcmp(argv[1], "rvds")) || (!strcmp(argv[1], "gas"))))
+ f = argv[1];
+
+ fd = open(f, O_RDONLY);
+
+ if (fd < 0)
+ {
+ perror("Unable to open file");
+ goto bail;
+ }
+
+ if (fstat(fd, &stat_buf))
+ {
+ perror("stat");
+ goto bail;
+ }
+
+ file_buf = malloc(stat_buf.st_size);
+
+ if (!file_buf)
+ {
+ perror("malloc");
+ goto bail;
+ }
+
+ if (read(fd, file_buf, stat_buf.st_size) != stat_buf.st_size)
+ {
+ perror("read");
+ goto bail;
+ }
+
+ if (close(fd))
+ {
+ perror("close");
+ goto bail;
+ }
+
+ res = parse_macho(file_buf, stat_buf.st_size);
+ free(file_buf);
+
+ if (!res)
+ return EXIT_SUCCESS;
+
+bail:
+ return EXIT_FAILURE;
+}
+
#elif defined(__ELF__)
#include "elf.h"
@@ -660,24 +740,96 @@ bail:
return 1;
}
+int main(int argc, char **argv)
+{
+ int fd;
+ output_fmt_t mode;
+ char *f;
+ struct stat stat_buf;
+ uint8_t *file_buf;
+ int res;
+
+ if (argc < 2 || argc > 3)
+ {
+ fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
+ fprintf(stderr, " <obj file>\tELF format object file to parse\n");
+ fprintf(stderr, "Output Formats:\n");
+ fprintf(stderr, " gas - compatible with GNU assembler\n");
+ fprintf(stderr, " rvds - compatible with armasm\n");
+ goto bail;
+ }
+
+ f = argv[2];
+
+ if (!strcmp(argv[1], "rvds"))
+ mode = OUTPUT_FMT_RVDS;
+ else if (!strcmp(argv[1], "gas"))
+ mode = OUTPUT_FMT_GAS;
+ else
+ f = argv[1];
+
+
+ fd = open(f, O_RDONLY);
+
+ if (fd < 0)
+ {
+ perror("Unable to open file");
+ goto bail;
+ }
+
+ if (fstat(fd, &stat_buf))
+ {
+ perror("stat");
+ goto bail;
+ }
+
+ file_buf = malloc(stat_buf.st_size);
+
+ if (!file_buf)
+ {
+ perror("malloc");
+ goto bail;
+ }
+
+ if (read(fd, file_buf, stat_buf.st_size) != stat_buf.st_size)
+ {
+ perror("read");
+ goto bail;
+ }
+
+ if (close(fd))
+ {
+ perror("close");
+ goto bail;
+ }
+
+ res = parse_elf(file_buf, stat_buf.st_size, mode);
+ free(file_buf);
+
+ if (!res)
+ return EXIT_SUCCESS;
+
+bail:
+ return EXIT_FAILURE;
+}
+#endif
#endif
-#endif /* defined(__GNUC__) && __GNUC__ */
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
+#if defined(_MSC_VER) || defined(__MINGW32__)
/* See "Microsoft Portable Executable and Common Object File Format Specification"
for reference.
*/
#define get_le32(x) ((*(x)) | (*(x+1)) << 8 |(*(x+2)) << 16 | (*(x+3)) << 24 )
#define get_le16(x) ((*(x)) | (*(x+1)) << 8)
-int parse_coff(uint8_t *buf, size_t sz)
+int parse_coff(unsigned __int8 *buf, size_t sz)
{
unsigned int nsections, symtab_ptr, symtab_sz, strtab_ptr;
unsigned int sectionrawdata_ptr;
unsigned int i;
- uint8_t *ptr;
- uint32_t symoffset;
+ unsigned __int8 *ptr;
+ unsigned __int32 symoffset;
char **sectionlist; //this array holds all section names in their correct order.
//it is used to check if the symbol is in .bss or .data section.
@@ -755,7 +907,7 @@ int parse_coff(uint8_t *buf, size_t sz)
for (i = 0; i < symtab_sz; i++)
{
- int16_t section = get_le16(ptr + 12); //section number
+ __int16 section = get_le16(ptr + 12); //section number
if (section > 0 && ptr[16] == 2)
{
@@ -826,21 +978,20 @@ bail:
return 1;
}
-#endif /* defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) */
int main(int argc, char **argv)
{
- output_fmt_t mode = OUTPUT_FMT_PLAIN;
+ int fd;
+ output_fmt_t mode;
const char *f;
- uint8_t *file_buf;
+ struct _stat stat_buf;
+ unsigned __int8 *file_buf;
int res;
- FILE *fp;
- long int file_size;
if (argc < 2 || argc > 3)
{
fprintf(stderr, "Usage: %s [output format] <obj file>\n\n", argv[0]);
- fprintf(stderr, " <obj file>\tobject file to parse\n");
+ fprintf(stderr, " <obj file>\tELF format object file to parse\n");
fprintf(stderr, "Output Formats:\n");
fprintf(stderr, " gas - compatible with GNU assembler\n");
fprintf(stderr, " rvds - compatible with armasm\n");
@@ -856,22 +1007,15 @@ int main(int argc, char **argv)
else
f = argv[1];
- fp = fopen(f, "rb");
-
- if (!fp)
- {
- perror("Unable to open file");
- goto bail;
- }
+ fd = _sopen(f, _O_BINARY, _SH_DENYNO, _S_IREAD | _S_IWRITE);
- if (fseek(fp, 0, SEEK_END))
+ if (_fstat(fd, &stat_buf))
{
perror("stat");
goto bail;
}
- file_size = ftell(fp);
- file_buf = malloc(file_size);
+ file_buf = malloc(stat_buf.st_size);
if (!file_buf)
{
@@ -879,30 +1023,19 @@ int main(int argc, char **argv)
goto bail;
}
- rewind(fp);
-
- if (fread(file_buf, sizeof(char), file_size, fp) != file_size)
+ if (_read(fd, file_buf, stat_buf.st_size) != stat_buf.st_size)
{
perror("read");
goto bail;
}
- if (fclose(fp))
+ if (_close(fd))
{
perror("close");
goto bail;
}
-#if defined(__GNUC__) && __GNUC__
-#if defined(__MACH__)
- res = parse_macho(file_buf, file_size);
-#elif defined(__ELF__)
- res = parse_elf(file_buf, file_size, mode);
-#endif
-#endif
-#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
- res = parse_coff(file_buf, file_size);
-#endif
+ res = parse_coff(file_buf, stat_buf.st_size);
free(file_buf);
@@ -912,3 +1045,4 @@ int main(int argc, char **argv)
bail:
return EXIT_FAILURE;
}
+#endif
« no previous file with comments | « libvpx/source/libvpx/build/make/gen_msvs_proj.sh ('k') | libvpx/source/libvpx/configure » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698