Coder Social home page Coder Social logo

Comments (3)

xavierleroy avatar xavierleroy commented on July 23, 2024

In CompCert, "asm" is a statement, like "return" or "if", so naturally it can only occur within a function body. This is consistent with ISO C99 J.5.10 ("The most common implementation is a statement of the form..."). I don't understand the purpose of a "top-level" asm statement like in the foo.c example. GCC just dumps a "cli" instruction outside of any function, where it will never be executed...

from compcert.

didickman avatar didickman commented on July 23, 2024

You're right, my example was not very good. Here's a better one:

#include <stdio.h>

__asm__( \
        ".section .gnu.warning." __STRING(gets)  \
        " ; .ascii \"" "gets() is unsafe." "\" ; .text");

int main(int argc, char **argv)
{
   char str[50];
   gets(str);
}

The above adds a warning anytime gets(3) is seen:

$ gcc foo.c
/tmp/ccVEAzyx.o: In function `main':
foo.c:(.text+0x26): warning: gets() is unsafe.

It can also be done outside of the compiler if needed:

$ ccomp -S foo.c
$ cat custom.s foo.s > foo.new.s
$ ccomp foo.new.s
foo.new.o(.text+0x14): In function `main':
: warning: gets() is unsafe

from compcert.

didickman avatar didickman commented on July 23, 2024

Perhaps we should close this one? It’s been a few years and as I point out it can be done outside of compcert? Leave the final decision to you all.

from compcert.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.